Displaying 1 result from an estimated 1 matches for "q_5a".
2012 Oct 13
3
Replace column values in R conditional on values from different column
...in it, except for the
initial NAs. I think R somehow inserted 0 instead of NAs for the gender
values which were not supposed to be in that column (i.e. replaced values
for females with 0 in the male column) but I don't know why.
Thanks!!!!!
for(i in 1:length(Health2$CohenSum)){
if (Health2$q_5a[i]==1) Health2$CohenM[i] <- Health2$CohenSum[i]
else if (Health2$q_5a[i]==2) Health2$CohenF[i] <- Health2$CohenSum[i]
else Health2$CohenF[i] <- NA
}
--
View this message in context: http://r.789695.n4.nabble.com/Replace-column-values-in-R-conditional-on-values-from-different-colum...