search for: myrecod

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

Did you mean: myrecord
2010 May 17
1
suggestions/improvements for recoding strategy
...suggestions. Thanks! # example input data myData <- read.table(textConnection("id, v1, v2, v3 a,1,2,3 b,1-2,,3-4 c,,3,4"),header=TRUE,sep=",") closeAllConnections() # the first column is IDs so remove that numdat <- myData[,-1] # function to change dashes: 1-2 to 1.5 myrecode <- function(mycol) { newcol <- mycol newcol <- gsub("1-2","1.5",newcol) newcol <- gsub("2-3","2.5",newcol) newcol <- gsub("3-4","3.5",newcol) newcol <- as.numeric(newcol) } newData <- data.frame(do.ca...