[R] Saving data in an R package - how to maintain that t avariable is a 'factor' when it is coded as 1, 2, 3...

From: Søren Højsgaard <Soren.Hojsgaard_at_agrsci.dk>
Date: Sat 14 Jan 2006 - 03:19:28 EST


I have a .txt file obtained by saving a data frame in which the first four columns are factors (but represented as 1,2,3 etc). The first four lines are  

"Pig" "Evit" "Cu" "Litter" "Start" "Weight" "Feed" "Time"
"4601" "1" "1" "1" 26.5 26.5 NA 1
"4601" "1" "1" "1" 26.5 27.59999 5.200005 2
"4601" "1" "1" "1" 26.5 36.5 17.6 3
"4601" "1" "1" "1" 26.5 40.29999 28.5 4

I would like to include that data set in an R-package. When I load the data from the package the first four columns are read in as numeric variables. This is consistent with the documentation of read.table - but it is not what I want! I can of course change the coding of the variables, but there ought to be another way. Can anyone help me on that? Best regards
Søren Højsgaard



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jan 14 03:36:03 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:04 EST