Re: [R] trouble with ifelse statement

2012-05-16 Thread Rui Barradas
Hello, 'sample' is a really bad name for a variable, it's already taken, it's an R function. sample>1 && sample<5 # '&&' is not vectorized, it's '&' you want. # Without 'ifelse' raw.saliva.data$max.cort[index] <- raw.saliva.data$cortisol[index & sample > 1 & sample < 5] Negate this last conj

Re: [R] trouble with ifelse statement

2012-05-16 Thread R. Michael Weylandt
It seems like your problem is that R can't find your variable "sample" and is instead finding its own sample() function which can't be compared to an integer and is giving your problem. It seems likely that sample is part of raw.saliva.data? If that's the case, change sample --> raw.saliva.data$sa

[R] trouble with ifelse statement

2012-05-16 Thread Melissa Rosenkranz
Hello, I apologize in advance for not providing sample data, I'm a very new to R and can't easily generate appropriate sample data quickly. I'm hoping someone can offer advice without it. This code below works and does what I want it to do, which is for a given row in my dataframe, where the vari