I am a novice to R. To use in a package I need a "data frame of factors".
I have a text file of form:
A B C ...
1 3 2
2 2 3
3 1 1
2 2 1
3 1 2
So each column represents a variable that can be 1, 2 or 3. Please suggest a command that allow me to get a Data Frame of factors from such a text file (just reading the file as a matrix won't do, I am required to have real 'factors').
Thanks in advance.
It seems that setting the colClasses
parameter of read.table
to:
colClasses = c(rep("factor",26))
would do the job I require.