[R] levels in dataframes
Peter Alspach
PAlspach at hortresearch.co.nz
Tue Apr 22 23:17:48 CEST 2008
Georg
One way is to call factor() on the subsetted object.
> georg <- factor(LETTERS[1:4])
> summary(georg)
A B C D
1 1 1 1
> georg <- georg[georg!='A']
> summary(georg) # the level is still there
A B C D
0 1 1 1
> georg <- factor(georg)
> summary(georg) # now it is gone
B C D
1 1 1
HTH ....
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Georg Ehret
> Sent: Wednesday, 23 April 2008 8:58 a.m.
> To: r-help
> Subject: [R] levels in dataframes
>
> Dear R community, I wish to ask a short question
> concerning factor-data
> in dataframes: When I subset the data and get rid of all data
> for one level, I still retain the level name (obtained by
> levels(dataframe$variablename) ).
> Is there a convenient way to get rid of the levels for which
> all data has been deleted?
> Thank you and wishing you an excellent day!
> Georg.
> ****************************************************
> Georg Ehret
> Johns Hopkins
> Baltimore, US
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
The contents of this e-mail are privileged and/or confidential to the named
recipient and are not to be used by any other person and/or organisation.
If you have received this e-mail in error, please notify the sender and delete
all material pertaining to this e-mail.
More information about the R-help
mailing list