[R] Assignment problems
R. Michael Weylandt
michael.weylandt at gmail.com
Mon Apr 23 23:21:21 CEST 2012
That's not the ifelse() that's the for loop returning NULL
(everything's a function!). If you put the assignment inside you'll
get expected behavior.
x <- (for(i in 1:5) i) # Strange
for(i in 1:5) x<- i # Normal (but notice you only get the last value
because previous ones are overwritten)
Michael
On Mon, Apr 23, 2012 at 4:26 PM, phillip03 <phillipbrigham at hotmail.com> wrote:
> Hi
>
>> EMU1993<-(for (i in 1:nrow(data)){
> + ifelse(year==1992,sum(avgflowEMU),0)
> + })
>
>>EMU1993
> NULL
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Assignment-problems-tp4578672p4581590.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.
More information about the R-help
mailing list