[R] sprintf + integer(0) problem

Henrique Dallazuanna wwwhsd at gmail.com
Thu Feb 25 02:03:25 CET 2010


You can use tryCatch also:

cat(tryCatch(sprintf('found %s in col %d\n', s, c), error =
function(x)cat('Not Found\n')))

On Wed, Feb 24, 2010 at 9:49 PM, esmail <esmail.js at gmail.com> wrote:
>
>
> Henrique Dallazuanna wrote:
>>
>> You can try this:
>>
>> cat(sprintf(ifelse(any(grepl(s, nn)), 'found %s in col %d\n', 'Column
>> %s not found'), s, match(s, nn)))
>>
>>
>
> Wow .. one can always learn something new .. that looks pretty complex, I
> have a bunch of print statements. I was hoping for a simpler solution so I
> guess for now I'll just comment out the sections that might cause problems
> under 2.8.0 (too bad, because it's useful to have some of this info
> displayed - which it does during development/testing, so it's ok).
>
> If anyone has a alternate solution, please let me know. In the meantime I'm
> going to try to use this code to determine if I should display the info or
> not:
>
> min = version[["minor"]]
> maj = version[["major"]]
> ver = paste(maj, '.',min, sep='')
>
> if (ver == "2.8.0") ...
>
>
> Cheers,
> Esmail
> --
> View this message in context: http://n4.nabble.com/sprintf-integer-0-problem-tp1567829p1568357.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list