[R] Order variables automatically
Debs Majumdar
debs_stata at yahoo.com
Tue Jan 1 06:10:42 CET 2013
Hi,
I have a dataset with 6 categorical variables. I have used this following code to make the variables u1-u6 ordered factors and this works well.
cat1cat2 cat3 cat4 cat5 cat6
0 1 1 0 0 1
1 1 0 0 0 0
.......
....
############
data<-read,table("example.txt")
data <- as.data.frame(lapply(data, ordered))
############
Now, suppose I have bigger dataset where some variables are categorical (cat) and others are continuous (cont)..
cat1 cat2 cont1 cont2 ...cont10 cat3 cont11....cat 40 cont25 etc.
Is there a way to code so that R goes through each variable and orders a variable if it is categorical and leaves a variable alone if it is continuous?
Thanks,
Debs
More information about the R-help
mailing list