Re: [R] Recoding variables based on reference values in data frame

2013-07-03 Thread arun
)  dim(res1New1)<- dim(res1New) identical(res1New1,res2) #[1] TRUE A.K. - Original Message ----- From: kathleen askland To: r-help@r-project.org Cc: Sent: Tuesday, July 2, 2013 4:46 PM Subject: [R] Recoding variables based on reference values in data frame I'm new to R (pre

Re: [R] Recoding variables based on reference values in data frame

2013-07-02 Thread Rui Barradas
Hello, If you have read in the data as factors (stringsAsFactors = TRUE, the default), change the function to the following. fun <- function(x){ x[x %in% c("nc", "_")] <- NA MM <- paste0(as.character(x[1]), as.character(x[1])) # Major Major Mm <- paste0(as.character(x

Re: [R] Recoding variables based on reference values in data frame

2013-07-02 Thread Rui Barradas
Hello, I'm not sure I understood, but try the following. Kgeno <- read.table(text = " SNP_ID SNP1 SNP2 SNP3 SNP4 Maj_Allele C G C A Min_Allele T A T G ID1 CC GG CT AA ID2 CC GG CC AA ID3 CC GGncAA ID4 _ _ _ _ ID5 CC GG CC AA ID6 CC GG CC

[R] Recoding variables based on reference values in data frame

2013-07-02 Thread kathleen askland
I'm new to R (previously used SAS primarily) and I have a genetics data frame consisting of genotypes for each of 300+ subjects (ID1, ID2, ID3, ...) at 3000+ genetic locations (SNP1, SNP2, SNP3...). A small subset of the data is shown below: SNP_ID SNP1 SNP2 SNP3 SNP4 Maj_Allele C G C A Min_A