[R] importing columns as factors

Erik Iverson eriki at ccbr.umn.edu
Sun May 23 09:11:31 CEST 2010


Caitlin Sadowski wrote:
> I have a large csv table I am trying to read into R. I would like each
> column to be of type factor. However, most columns have only numeral
> entries (e.g. likert scales), so are automatically imported as type
> numeric. Is there a way to convert ALL columns to be of type factor,
> without having to convert each column manually?

It's in the help file for ?read.csv, the colClasses argument:

colClasses: character.  A vector of classes to be assumed for the
           columns.  Recycled as necessary, or if the character vector
           is named, unspecified values are taken to be ‘NA’.



More information about the R-help mailing list