Monday, June 4, 2012


Code:
# This command will create a new high-dimensional list which will contain the 
# value "gain" for all variables which had a numerical value between 0.5 and 1,
# as well as the value "NA" for all variables with values between 0 and 0.5
probgain.recoded<-
+lapply(probgain, 
+function(x) 
+recode(x, recodes="0.5:1='gain'; 0:0.5=NA", as.factor.result = FALSE))
# now we're turning this list into a data.frame again and attaching 
# the col and rownames from the original data frame
probgain.recoded<-data.frame(probgain.recoded)
colnames(probgain.recoded)<-colnames(probgain)
rownames(probgain.recoded)<-rownames(probgain)

No comments:

Post a Comment