Friday 15 June 2012

r - How do I count / display the number of each outcome from a random sample? -



r - How do I count / display the number of each outcome from a random sample? -

i'm taking sample of size 1000 of different (pet) animals. code

pet <- sample(c("dog","cat","hamster","goldfish"), 1000, replace = true)

i want see how many times "dog" selected, "cat" selected, etc. i've tried summary(pet) wasn't much help / told me length 1000 , characters.

try in r:

> table(pet) pet cat dog goldfish hamster 241 284 225 250

r sample

No comments:

Post a Comment