Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print(sample(1:3))
- print(sample(1:3, size=3, replace=FALSE)) # same as previous line
- print(sample(c(2,5,3), size=4, replace=TRUE))
- print(sample(1:2, size=10, prob=c(1,3), replace=TRUE))
- print(sample(c(2,5,3), size=3, replace=FALSE))
- print(sample(c(2,5,3), size=3, replace=TRUE))
- barplot(table(sample(1:3, size=1000, replace=TRUE, prob=c(.30,.60,.10))))
- install.packages("plyr")
- library(plyr)
- ds <- matrix(c(sample(1:3,6,replace=T),sample(4:6,6,replace=T)),ncol=2)
- #ds is the generated dataset, your data would go here
- apply(ds,2,count)
- # [[1]]
- # x freq
- # 1 1 1
- # 2 2 3
- # 3 3 2
- # [[2]]
- # x freq
- # 1 4 1
- # 2 5 1
- # 3 6 4
Advertisement
Add Comment
Please, Sign In to add comment