[R] removed data is still there!

pdb philb at philbrierley.com
Tue Sep 21 13:41:31 CEST 2010


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.



More information about the R-help mailing list