Skip to content
Prev 325313 / 398503 Next

Remove levels

Works fine for me. Too bad you didn't include actual data:
"river"),
+         15, replace=TRUE)), Var=sample.int(100, 15))
UnitName_1 Var
1       river  95
2       river  97
3        lake  12
4       river  47
5        pond  54
6        pond  86
7       river  14
8        lake  92
9        pond  88
10      river   8
11       pond  99
12      river  35
13      river  80
14       lake  39
15       pond  72
[1]  3  8 14
UnitName_1 Var
1       river  95
2       river  97
4       river  47
5        pond  54
6        pond  86
7       river  14
9        pond  88
10      river   8
11       pond  99
12      river  35
13      river  80
15       pond  72

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Shane Carey
Sent: Thursday, June 13, 2013 7:03 AM
To: r-help at r-project.org
Subject: [R] Remove levels

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
appreciated.

Thanks