[R] Remove levels

2013-06-13 Thread 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 In the past this worked for me, but its not working now. Any help

Re: [R] Remove levels

2013-06-13 Thread Albin Blaschka
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

Re: [R] Remove levels

2013-06-13 Thread Shane Carey
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:

Re: [R] Remove levels

2013-06-13 Thread Jeff Newmiller
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]

Re: [R] Remove levels

2013-06-13 Thread David Carlson
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

Re: [R] Remove levels

2013-06-13 Thread Alain Guillet
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

Re: [R] Remove levels

2013-06-13 Thread arun
' 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

Re: [R] Remove levels

2013-06-13 Thread David Carlson
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

Re: [R] remove levels from a factor

2008-08-30 Thread Adrian Dusa
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 __

Re: [R] remove levels from a factor

2008-08-30 Thread Frank E Harrell Jr
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

[R] remove levels from a factor

2008-08-29 Thread Yuan Jian
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]]

Re: [R] remove levels from a factor

2008-08-29 Thread milton ruser
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