How do I convert certain columns of a data frame to become factors? [duplicate]
Possible Duplicate: identifying or coding unique factors using R I'm having some trouble with R. I have a data set similar to the following, but much longer. A B Pulse 1 2 23 2 2 24 2 2 12 2 3 25 1 1 65 1 3 45 Basically, the first 2 columns are coded. A has 1, 2 which represent 2 different weights. B has 1, 2, 3 which represent 3 different times. As they are coded numerical values, R will treat them as numerical variables. I need to use the factor function to convert these variables into factors. Help? Here's an example: #Create a data frame > d<- data.frame(a=1:3, b=2:4) > d a b 1 1 2 2 2 3 3