Re: [R] sprintf + integer(0) problem

2010-02-24 Thread Esmail
On 24-Feb-10 20:03, Henrique Dallazuanna wrote: You can use tryCatch also: cat(tryCatch(sprintf('found %s in col %d\n', s, c), error = function(x)cat('Not Found\n'))) Ah .. one more way .. thanks, I've saved it away in my set of R tricks! Best, Esmail

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Esmail > Sent: Wednesday, February 24, 2010 10:07 AM > To: r-help@r-project.org > Subject: [R] sprintf + integer(0) problem > > Hello all, > >

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread Henrique Dallazuanna
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 wrote: > > > Henrique Dallazuanna wrote: >> >> You can try this: >> >> cat(sprintf(ifelse(any(grepl(s, nn)), 'found %s in col %d\n', 'Col

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread esmail
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 s

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread Henrique Dallazuanna
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))) On Wed, Feb 24, 2010 at 3:06 PM, Esmail wrote: > Hello all, > > I am stuck with R v2.8.0 under Linux for the time being and I am > running into a small problem that doesn't e

[R] sprintf + integer(0) problem

2010-02-24 Thread Esmail
Hello all, I am stuck with R v2.8.0 under Linux for the time being and I am running into a small problem that doesn't exist under 2.9.x and 2.10.x with sprintf. If I have the following code segment to help me determine the column number for a specific column header/label: nn = names(Dataset)