Re: [R] ifelse(is.na), with function inside

2009-06-19 Thread Grześ
:) Thank you very much! I have already found solution. I have always problem with connect logical value and vector :/ You know... everybody helped me a little. Thanks very much again! Grzesiek Petr Pikal wrote: > > Hi > > r-help-boun...@r-project.org napsal dne 17.06.2009 14:59:35: > >> >

Re: [R] ifelse(is.na), with function inside

2009-06-19 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.06.2009 14:59:35: > > This is my function: > > zywnoscCalosc <- function( zywnosc, sklepik, sklslodycze) { > > b=as.vector(sklslodycze) > > fun=function(a,b){ > a=2+b > } > zywnosc=ifelse(is.na(sklepik),NA,fun(a,b))#Here I have a problem

Re: [R] ifelse(is.na), with function inside

2009-06-17 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Grzes > Sent: Tuesday, June 16, 2009 10:51 PM > To: r-help@r-project.org > Subject: Re: [R] ifelse(is.na), with function inside > > > 2 - is.na(a)

Re: [R] ifelse(is.na), with function inside

2009-06-17 Thread Grześ
This is my function: zywnoscCalosc <- function( zywnosc, sklepik, sklslodycze) { b=as.vector(sklslodycze) fun=function(a,b){ a=2+b } zywnosc=ifelse(is.na(sklepik),NA,fun(a,b))#Here I have a problem ! } I always get: Error in 2 + b : non-numeric argument to binary operator I think prob

Re: [R] ifelse(is.na), with function inside

2009-06-17 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.06.2009 07:51:27: > > 2 - is.na(a) - it's superb! but I need call a function: wy[i]<- > ifelse(((is.na(a))), call_fun1(x), call_fun2(x) You did not grasp how to use ifelse. It goes not cycle through logical vector is.na(a). from help page Argum

Re: [R] ifelse(is.na), with function inside

2009-06-17 Thread Grześ
2 - is.na(a) - it's superb! but I need call a function: wy[i]<- ifelse(((is.na(a))), call_fun1(x), call_fun2(x) Gabor Grothendieck wrote: > > Try: > > 2 - is.na(a) > > > On Tue, Jun 16, 2009 at 5:46 PM, Grześ wrote: >> >> Hi, >> I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like

Re: [R] ifelse(is.na), with function inside

2009-06-16 Thread joscani
Try: b<- ifelse(is.na(a),1,2) Grześ wrote: > > 2 - is.na(a) - it's superb! but I need call a function: wy[i]<- > ifelse(((is.na(a))), call_fun1(x), call_fun2(x) > > > > Gabor Grothendieck wrote: >> >> Try: >> >> 2 - is.na(a) >> >> >> On Tue, Jun 16, 2009 at 5:46 PM, Grześ wrote: >>> >

Re: [R] ifelse(is.na), with function inside

2009-06-16 Thread Gabor Grothendieck
Try: 2 - is.na(a) On Tue, Jun 16, 2009 at 5:46 PM, Grześ wrote: > > Hi, > I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like to use is.na(a) > function to get a vector like this: > wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in > vector "a" > > This is my

[R] ifelse(is.na), with function inside

2009-06-16 Thread Grześ
Hi, I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like to use is.na(a) function to get a vector like this: wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in vector "a" This is my short code but something is wrong and I don't know what... for (i in 1:7){ a