example(factor)
iris1$Species <- factor(iris1$Species, drop=T)
will get you what you need.
Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina
nikhil.l...@gmail.com
On Sep 21, 2010, at 7:41 AM, pdb wrote:
I'm confused, hope someone can point out what is not obvious to me.
I thought I was creating a new data frame by 'deleting' rows from an
existing dataframe - I've tried 2 methods.
But this new data frame seems to remember values from its parent -
even
though there are no occurences.
Where does it get the values versicolor and virginica from and give
then a
count of 0?
What am I missing?
Thanks in advance.
summary(iris$Species)
setosa versicolor virginica
50 50 50
nrow(iris)
[1] 150
iris1 <- iris[iris$Species == 'setosa',]
nrow(iris1)
[1] 50
summary(iris1$Species)
setosa versicolor virginica
50 0 0
boxplot(Petal.Width ~ Species, data = iris1, plot=1)
iris2 <- subset(iris, Species == 'setosa')
nrow(iris2)
[1] 50
summary(iris2$Species)
setosa versicolor virginica
50 0 0
boxplot(Petal.Width ~ Species, data = iris2, plot=1)
--
View this message in context:
http://r.789695.n4.nabble.com/removed-data-is-still-there-tp2548440p2548440.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.
______________________________________________
R-help@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.