Re: [R] Stumped with subsetting

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Fri 30 Jul 2004 - 12:20:41 EST

Peter Wilkinson <pwilkinson <at> videotron.ca> writes:

:
: Hi there,
:
: thanks for the reply. I was expecting what Tony posted. By the way I got
: the format for my question out of Introduction to R. So I expected it to
: work as in the text, but it turns out ....
:
: my "list" somehow was not a vector:
:
: > list[1]
: [1] PERH0125
: 44 Levels: PERH0015 PERH0019 PERH0023 PERH0029 PERH0037 PERH0045 PERH0053
: PERH0075 ... PERH0360
:
: I did the following:
:
: > list2 = as.vector(list)
: > list2
: [1] "PERH0125" "PERH0315" "PERH0161" "PERH0181" "PERH0229" "PERH0223"
: "PERH0243" "PERH0269"
: <snip>
:
: I am not sure what format list was in (looks like factor), but I turned it
: into a vector and it worked as expected. I have to go back and see how I
: created list in the first place.
:
: originally I took a row from a data frame, removed NA values, then sorted
: it into an order that I wanted (using 'order') .... so I don't know when it
: turned into something that looked like factor. Any ?

read.table will read characters in as factors unless you specify otherwise. See ?read.table and the as.is= argument in particular.



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 30 12:25:25 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:22 EST