i surprised there seems no question problem. @ least haven't found accurate answer.
suppose easy case of rolling 2 dices , adding pips shown. possible results range 2 12. want plot histogram event, i.e. 1 bin per possible number. make 11 bins (2,3,4,5...12)
# example dataset: how did "2","3", "4"(1x2, 3x3, 2x4, 4x5, 8x6, 14x7, ...) dice <- c(2,rep(3,3),rep(4,2),rep(5,4),rep(6,8),rep(7,14),rep(8,9),rep(9,5),rep(10,4),rep(11,1),rep(12,2)) hist(dice,breaks=seq(2,12)) # custom breaks return 10 bins (9 breaks) hist(dice,breaks=11) # same automatic breaks (and breaks=12 or 13...) what need histogram plot 11 bins - 1 bin per possible result. how can trick r doing this?
thank you!
hist(dice,breaks=seq(1.5,12.5)) 
Comments
Post a Comment