[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

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 gangch...@gmail.com wrote: n = c(2, 3, 5) s =

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 r...@stanford.edu wrote: See the max.levels argument in ?print. I think this is what you're looking for.

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 gangch...@gmail.com wrote: A very

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 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 spec...@stat.berkeley.edu wrote: Gang -   It sounds like you want your character variables to be stored as character values, not

[R] short question about data frame manipulation

2010-04-30 Thread arnaud Gaboury
Dear group, I am losing my mind with a simple question. Sorry if obvious, but I maybe start to be confused after days and days of reading documentations. Df : df - structure(list(a = 1:3, b = 4:6, c = structure(c(1L, 1L, 1L), class = factor, .Label = w)), .Names = c(a, b, c), row.names =

Re: [R] short question about data frame manipulation

2010-04-30 Thread David Winsemius
On Apr 30, 2010, at 9:08 AM, arnaud Gaboury wrote: Dear group, I am losing my mind with a simple question. Sorry if obvious, but I maybe start to be confused after days and days of reading documentations. Df : df - structure(list(a = 1:3, b = 4:6, c = structure(c(1L, 1L, 1L), class =

Re: [R] short question about data frame manipulation

2010-04-30 Thread Lanna Jin
df[1:2]-df[1:2]*-1 - Lanna Jin lanna...@gmail.com 510-898-8525 -- View this message in context: http://r.789695.n4.nabble.com/short-question-about-data-frame-manipulation-tp2076891p2076899.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] short question about data frame manipulation

2010-04-30 Thread Dennis Murphy
Hi: On Fri, Apr 30, 2010 at 6:08 AM, arnaud Gaboury arnaud.gabo...@gmail.comwrote: Dear group, I am losing my mind with a simple question. Sorry if obvious, but I maybe start to be confused after days and days of reading documentations. Df : df - structure(list(a = 1:3, b = 4:6, c =