Hi Nick, On Wed, Feb 16, 2011 at 7:28 AM, Nick Riches <nick.ric...@gmail.com> wrote: > Hi > > I've resolved the following query by adding the option "stringsAsFactors = > FALSE"
Sure, that works, but it doesn't explain why as.is="stim" didn't work. Unfortunately I cannot reproduce: > dat <- data.frame(stim=letters[10], x=1:10) > write.table(dat, file="test.dat", sep=",") > tmp1 <- read.table(file="test.dat", header=T, sep=",") > tmp2 <- read.table(file="test.dat", header=T, sep=",", as.is="stim") > str(tmp1) 'data.frame': 10 obs. of 2 variables: $ stim: Factor w/ 1 level "j": 1 1 1 1 1 1 1 1 1 1 $ x : int 1 2 3 4 5 6 7 8 9 10 > str(tmp2) 'data.frame': 10 obs. of 2 variables: $ stim: chr "j" "j" "j" "j" ... $ x : int 1 2 3 4 5 6 7 8 9 10 > > sessionInfo() R version 2.11.1 (2010-05-31) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] ggplot2_0.8.9 proto_0.3-8 reshape_0.8.3 plyr_1.2.1 loaded via a namespace (and not attached): [1] digest_0.4.2 tools_2.11.1 Best, Ista > > Thanks > > Nick Riches > > ---------- Forwarded message ---------- > From: Nick Riches <nick.ric...@gmail.com> > Date: 16 February 2011 12:16 > Subject: read.table - reading text variables as text > To: r-help@r-project.org > > > Hi > > I'm reading a CSV file using read.table, and it keeps importing a text > variable as a factor. To overcome this, I've used the as.is command > referring to the variable in question (called "stim") > > data<-read.table(file.choose(), header=T, sep=",", as.is = "stim") > > However, "stim" is still imported as a factor. I notice there are other > read.table options related to this issue, but the help files don't appear to > contain much detail on these. > > Any help would be greatly appreciated. > > Best wishes > > Nick Riches > > -- > Lecturer in Speech and Language Pathology > Room 1.9 > King George VI Building > Queen Victoria Road > University of Newcastle-upon Tyne > NE1 7RU > > 0191 222 8720 > > > > -- > Lecturer in Speech and Language Pathology > Room 1.9 > King George VI Building > Queen Victoria Road > University of Newcastle-upon Tyne > NE1 7RU > > 0191 222 8720 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.