Re: [R] A question about data frame

2011-03-10 Thread Gang Chen
Yes, indeed I wanted them stored as characters instead of factor levels. Thanks a lot for the help, Jim and Phil! Gang On Thu, Mar 10, 2011 at 5:19 PM, Phil Spector wrote: > Gang - >   It sounds like you want your character variables to > be stored as character values, not factor values.  If tha

Re: [R] A question about data frame

2011-03-10 Thread Phil Spector
Gang - It sounds like you want your character variables to be stored as character values, not factor values. If that's the case, use df = data.frame(n, s,stringsAsFactors=FALSE) If you want them to be factors, but not to display as factors, others have provided usable solutions.

Re: [R] A question about data frame

2011-03-10 Thread jim holtman
try this: > n = c(2, 3, 5) > s = c("aa", "bb", "cc") > df = data.frame(n, s, stringsAsFactors = FALSE) > df n s 1 2 aa 2 3 bb 3 5 cc > str(df) 'data.frame': 3 obs. of 2 variables: $ n: num 2 3 5 $ s: chr "aa" "bb" "cc" > On Thu, Mar 10, 2011 at 4:35 PM, Gang Chen wrote: > A very simpl

Re: [R] A question about data frame

2011-03-10 Thread Gang Chen
Thanks! You mean something like: > print(df$s[1], max.levels=0) It seems I could also do > as.character(df$s[1]) Any other/better solutions? On Thu, Mar 10, 2011 at 4:40 PM, Rob Tirrell wrote: > See the max.levels argument in ?print. I think this is what you're looking > for. > -- > Robert Ti

Re: [R] A question about data frame

2011-03-10 Thread Rob Tirrell
See the max.levels argument in ?print. I think this is what you're looking for. -- Robert Tirrell | r...@stanford.edu | (607) 437-6532 Program in Biomedical Informatics | Butte Lab | Stanford University On Thu, Mar 10, 2011 at 13:35, Gang Chen wrote: > n = c(2, 3, 5) > > s = c("aa", "bb", "cc"

[R] A question about data frame

2011-03-10 Thread Gang Chen
A very simple question. With a data frame like this: > n = c(2, 3, 5) > s = c("aa", "bb", "cc") > df = data.frame(n, s) I want df$s[1] or df[1,2], but how can I get rid of the extra line in the output about the factor levels: > df$s[1] [1] aa Levels: aa bb cc Thanks, Gang _