Skip to content

character vectors in data.frames

2 messages · Lorenz Gygax, Peter Dalgaard

#
Dear all,

well, today I just seem to run into these problems ... (I am still working
on R 0.63.1 on a SuSE 5.2). I would like to have a data.frame that also
contains character (and NOT factor) vectors. Two things that I tried (the
second worked in R 0.62.2):
Warning: invalid factor level, NAs generated

or:
[1] TRUE
[1] FALSE

Any suggestions how to achieve this? Many thanks!

--			~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lorenz Gygax		 LGygax at amath.unizh.ch;       room: 36-L-40
			 Department of Applied Mathematics
			 University of Zuerich-Irchel
			 Winterthurerstr. 190; CH-8057 Zurich
			 voice: 41-1-635-58-52  fax: 41-1-635-57-05
			~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Lorenz Gygax <lgygax at access.unizh.ch> writes:
Use I(). Like this:
X
1 a
2  
3  
4
[1] "a" ""  ""  "" 
attr(,"class")
[1] "AsIs"

And yes, the behaviour that data.frame converts character to factor
unless requested otherwise is weird, but Splus compatible.