Hello everybody, I've got a problem concerning the function unique. I have got a data.frame "shopdata" with 1000 shop which were evaluated at different points in time. With function subset I chose those shops with more then 10 employee and store it in data.frame "bigshopdata" with 700 shops. bigshopdata=subset(shopdata, shopdata$employee>10) Now I use unique(bigshopdata$name) to ensure that each shop name is only listed ones and not two or three times because of an evaluation at different dates. What happens is that unique eliminates also those shops names which appear only ones in bigshopdata but twice or more often in shopdata. But that is not what I want to. I'm only interessted in multiple appearance in bigshopdata not in an possible multible appearance in the original data.farme. How can I use unique to get what I want? Or is there an alternative function? I hope I explained the problem good enought. Best regards Claudia
Le mardi 16 octobre 2012 ? 14:45 +0200, paladini a ?crit :> Hello everybody, > I've got a problem concerning the function unique. I have got a > data.frame "shopdata" with 1000 shop which were evaluated at different > points in time. > > With function subset I chose those shops with more then 10 employee and > store it in data.frame "bigshopdata" with 700 shops. > bigshopdata=subset(shopdata, shopdata$employee>10) > > Now I use unique(bigshopdata$name) to ensure that each shop name is > only listed ones and not two or three times because of an evaluation at > different dates. > > What happens is that unique eliminates also those shops names which > appear only ones in bigshopdata but twice or more often in shopdata. > > > But that is not what I want to. I'm only interessted in multiple > appearance in bigshopdata not in an possible multible appearance in the > original data.farme. > > > How can I use unique to get what I want? Or is there an alternative > function?Please provide a reproducible example with a subset of your data, or with sample data. Your problem does not make sense to me. In particular, unique() does not "eliminate" as you say, it retains all values that appear at least once; so a value appearing twice or more will not be eliminated. Regards
If I understand your problem correctly (as Milan has pointed out, sample data and code would help enormously) this should get you where you want: unique( shopdata$name[ shopdata$employee > 10 ] ) If not, something is wrong from the outset (or with my understanding, but then ... see above)! Rgds, Rainer On Tuesday 16 October 2012 14:45:37 paladini wrote:> Hello everybody, > I've got a problem concerning the function unique. I have got a > data.frame "shopdata" with 1000 shop which were evaluated at different > points in time. > > With function subset I chose those shops with more then 10 employee and > store it in data.frame "bigshopdata" with 700 shops. > bigshopdata=subset(shopdata, shopdata$employee>10) > > Now I use unique(bigshopdata$name) to ensure that each shop name is > only listed ones and not two or three times because of an evaluation at > different dates. > > What happens is that unique eliminates also those shops names which > appear only ones in bigshopdata but twice or more often in shopdata. > > > But that is not what I want to. I'm only interessted in multiple > appearance in bigshopdata not in an possible multible appearance in the > original data.farme. > > > How can I use unique to get what I want? Or is there an alternative > function? > > > I hope I explained the problem good enought. > > Best regards > > > Claudia > > ______________________________________________ > 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.- - - - - Boycott Apple! http://i.eatliver.com/2012/9362.jpg http://blogs.computerworlduk.com/simon-says/2012/09/iphone-5-misses-standardisation-opportunity/index.htm