I want to change the data type to factor. The data shown in the example below has only three variables. So, if you want to change the data type to factor, you can type code 3times like this.
>str(zxc2)
'data.frame': 50000 obs. of 3 variables:
$ CA0000005: int 1 1 2 2 1 1 2 1 5 1 ...
$ CA0000008: int 1 0 2 2 1 1 2 1 1 0 ...
$ CA0000602: int 0 832 3077 3155 0 0 0 0 995 2712 ...
>zxc2$CA0000005<-as.factor(zxc2$CA0000005)
>zxc2$CA0000008<-as.factor(zxc2$CA0000008)
>zxc2$CA0000602<-as.factor(zxc2$CA0000602)
However, if there are a lot of variables, it is hard to input each one as above. If all variables need to be changed to factor, how can i change them at once?
Thanks in advance for your reply.