[R] Stumped with subsetting
ggrothendieck at myway.com
Fri Jul 30 04:20:41 CEST 2004
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
:  PERH0125
: 44 Levels: PERH0015 PERH0019 PERH0023 PERH0029 PERH0037 PERH0045 PERH0053
: PERH0075 ... PERH0360
: I did the following:
: > list2 = as.vector(list)
: > list2
:  "PERH0125" "PERH0315" "PERH0161" "PERH0181" "PERH0229" "PERH0223"
: "PERH0243" "PERH0269"
: 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.
More information about the R-help