search for: health2

Displaying 2 results from an estimated 2 matches for "health2".

Did you mean: health
2012 Oct 13
3
Replace column values in R conditional on values from different column
...but instead every cell has values 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...
2012 Sep 27
3
Keep rows in a dataset if one value in a column is duplicated
...or atomic vectors". I am just beginning to learn R, so I apologize if the code is really rough. Basically I want to keep all the rows in the data set for which the value of "Pairiddups" is TRUE. How do I do it? And how do I get past the error? Thank you so much, Diana PairID<-c(Health2$pairid) duplicated(PairID, incomparables=TRUE, fromLast=TRUE) PairIDdup=duplicated(PairID) cbind(PairID, PairIDdup) PairID[which(PairIDdup)] PairIDDuplicates<-PairID%in%PairID[which(PairIDdup)] PairIDs<-cbind(PairID, PairIDDuplicates) colnames(PairIDs)<-c("Pairid","Pairi...