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
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.
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
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
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"
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
_
6 matches
Mail list logo