I have a dataframe consisting of factors in one column. Im trying to remove
certain levels using the following code:
toBeRemoved1-which(DATA$UnitName_1==lake)
DATA-DATA[-toBeRemoved1,]
However it will not remove the level lake
In the past this worked for me, but its not working now. Any help
Am 13.06.2013 14:02, schrieb Shane Carey:
I have a dataframe consisting of factors in one column. Im trying to remove
certain levels using the following code:
toBeRemoved1-which(DATA$UnitName_1==lake)
DATA-DATA[-toBeRemoved1,]
However it will not remove the level lake
Hello!
Is this a part
Nope, but thanks
On Thu, Jun 13, 2013 at 1:11 PM, Albin Blaschka
albin.blasc...@standortsanalyse.net wrote:
Am 13.06.2013 14:02, schrieb Shane Carey:
I have a dataframe consisting of factors in one column. Im trying to
remove
certain levels using the following code:
Please read the Posting Guide, which among other things points out that you
should be posting in plain text format, not HTML (which tends to corrupt
example R code).
Then please explain why your problem is not addressed by the below referenced
section of the R Inferno. You may need to read [1]
Professor of Anthropology
Texas AM University
College Station, TX 77840-4352
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Shane Carey
Sent: Thursday, June 13, 2013 7:03 AM
To: r-help@r-project.org
Subject: [R] Remove levels
I have
Hi,
Without more information I guess your problem is that the level name
still exists in the factor whereas it doesn't appear anymore in the
factor. If so, try droplevels.
Alain Guillet
On 13/06/13 14:02, Shane Carey wrote:
I have a dataframe consisting of factors in one column. Im trying
' careys...@gmail.com; r-help@r-project.org
Cc:
Sent: Thursday, June 13, 2013 10:00 AM
Subject: Re: [R] Remove levels
Works fine for me. Too bad you didn't include actual data:
set.seed(42)
DATA - data.frame(UnitName_1=factor(sample(c(lake, pond,
river),
+ 15, replace=TRUE)), Var=sample.int
Subject: Re: [R] Remove levels
Works fine for me. Too bad you didn't include actual data:
set.seed(42)
DATA - data.frame(UnitName_1=factor(sample(c(lake, pond,
river),
+ 15, replace=TRUE)), Var=sample.int(100, 15))
DATA
UnitName_1 Var
1 river 95
2 river 97
3lake
Yuan Jian jayuan2008 at yahoo.com writes:
[...snip...]
I want to remove level b because level b has less than 2.
f
[1] a a
Levels: a
f[which(f %in% names(table(f))[table(f) = 2]), drop=TRUE]
[1] a a
Levels: a
HTH,
Adrian
__
Adrian Dusa wrote:
Adrian Dusa dusa.adrian at gmail.com writes:
[...snip...]
f[which(f %in% names(table(f))[table(f) = 2]), drop=TRUE]
[1] a a
Levels: a
Or, more simple:
f[f %in% names(table(f))[table(f) = 2], drop=TRUE]
[1] a a
Levels: a
Adrian
Also see the combine.levels function in
Hi,
how to remove levels that have less than a specific number such as 2. i.e..
f-as.factor(c(a,b,a))
f
[1] a b a
Levels: a b
I want to remove level b because level b has less than 2.
f
[1] a a
Levels: a
[[alternative HTML version deleted]]
Hi Yuan,
It is not ellegant, but may work for you..
f-as.factor(c(a,b,a))
f.freq-data.frame(table(f))
f.freq
lower.freq-2
f.freq.subset-subset(f.freq,f.freq$Freq=lower.freq)
f.freq.subset
f.selected-f[f %in% f.freq.subset$f]
f.selected-factor(f.selected)
f.selected
Best wishes,
miltinho
12 matches
Mail list logo