I have come across simple problem in R and I was hoping 

someone out there could help me out.  Here is the problem: I am trying to
set up and rep statement with a conditional statement using ifelse.  Here is
simple example.

 

> y=5

> o<-ifelse(y==5,rep(2,4),NA)

> o

> [1] 2

>  

> If I check my conditional

> 

> > y==5

> 

> [1] TRUE

> 

> And if I check my assignment

> 

> > rep(2,4)

> 

> [1] 2 2 2 2

> 

>So why does this not work within the ifelse statement?  Any help will be
much appreciated.

> 

> 

 


	[[alternative HTML version deleted]]

