Try this:
> bargin$stuffnew<-bargin$stuff[bargin$stuff != "very.high",
drop=TRUE]
> bargin$stuffnew
[1] low middle low low low low middle low middle
middle middle middle middle high
[15] high low middle middle low high
Levels: low middle high>
On Wed, Jul 29, 2009 at 8:47 PM, Jason Rupert<jasonkrupert at yahoo.com>
wrote:> Code is provided below.
>
> I was trying to follow the example at the following website:
> http://www.ats.ucla.edu/stat/R/modules/factor_variables.htm
>
> Only difference is that I am working with trying to remove a level from a
dataframe. ?In the example below, notice that "very.high" is still a
level in bargin$stuffnew, even though I thought I removed it.
>
> Thanks for info on what I might have overlooked to remove
"very.high" level and if I can do it after the fact from
bargin$stuffnew.
>
> Thanks again.
>
> bargin<-NULL
> ses<-NULL
> ses <- c("low", "middle", "low",
"low", "low", "low", "middle",
"low", "middle", "middle", "middle",
"middle", "middle", "high", "high",
"low", "middle", "middle", "low",
"high")
> bargin$stuff <- factor(ses, levels = c("low",
"middle", "high"))
> bargin$stuff
> bargin$stuff<-factor(bargin$stuff, levels = c(levels(bargin$stuff),
"very.high"))
> bargin$stuff
> bargin$stuffnew<-bargin$stuff[bargin$stuff != "very.high"]
> bargin$stuffnew
> ?[1] low ? ?middle low ? ?low ? ?low ? ?low ? ?middle low ? ?middle middle
middle middle middle high
> [15] high ? low ? ?middle middle low ? ?high
> Levels: low middle high very.high
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?