[R] removed data is still there!

Peter Ehlers ehlers at ucalgary.ca
Thu Sep 23 22:35:41 CEST 2010


On 2010-09-21 5:51, Nikhil Kaza wrote:
> example(factor)
>
> iris1$Species<- factor(iris1$Species, drop=T)
>
> will get you what you need.

Hmm, doesn't work for me. ?factor does not list a 'drop='
argument.

   -Peter Ehlers

>
>
> Nikhil Kaza
> Asst. Professor,
> City and Regional Planning
> University of North Carolina
>
> nikhil.list at 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 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.
>



More information about the R-help mailing list