How to change the data type of all variables to factor at once : <p>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.</p>

<pre><code>&gt;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 ...

&gt;zxc2$CA0000005&lt;-as.factor(zxc2$CA0000005)
&gt;zxc2$CA0000008&lt;-as.factor(zxc2$CA0000008)
&gt;zxc2$CA0000602&lt;-as.factor(zxc2$CA0000602)
</code></pre>

<p>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?</p>

<p>Thanks in advance for your reply.</p>
