search for: thevector

Displaying 1 result from an estimated 1 matches for "thevector".

2008 Oct 01
2
an unsophisticated question about recoding in a data frame with control structure if {}
Hello all, I apologize for a terribly simple question. I'm used to using Stata and am trying to `switch' over to R. I would like to recode a vector in a data frame when the value of it meets the following condition: if (dataframe$factor=='3'){dataframe$thevector<-(an arithmetic mean). What I would like to result is the creation of a new variable within the data frame for which all observations that =='3' get the mean. Yet, I receive an error message that R is only reading the first element of the factor: Warning message: In if (nes2004$Rrac...