I am having a hard time understanding what is happening with ifelse.

Let me illustrate:

h <- numeric(5)
p <- 1:5
j <- floor(j)
x <- 1:1000
 ifelse(h == 0, x[j+2], 1:5)
[1] 2 3 4 5 6

My question is, "shouldn't this be retruning 25 numbers?" It seems that the 
ifelse should check 5 values of h for zero. For each of the 5 values I am 
thinking it should return an array of 5 (x[j+2] if h[index] == 0). Since the 
dimension of h is 5 that would mean 25 values. But that isn't what is being 
returned.Something about this that I don't understand. Please help my ignorance.

Thank you.

Kevin

______________________________________________
R-help@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.

Reply via email to