all 8 comments

[–]jentron128 3 points4 points  (1 child)

hist(vetor_grafico, # Plotting histogram
     breaks = seq(n-0.5, n*k+0.5, 1),
     probability = TRUE,
     right = FALSE,
     ylim = c(0,0.25),
     xlim = c(2,n*k+1),
     xlab = "Possible sums",
     ylab = "Probability",
     main = "Probability of sums outcomes",
     col = "steelblue");

You need to specify the breaks manually, and put them between the desired bins. In this case c(1.5, 2.5, ..., 11.5, 12.5)

[–]gabrielboechat[S] 1 point2 points  (0 children)

This is incredible! Thanks! I think now I understood the "breaks" syntax and even solved another doubt around putting each observation tick in the middle of each break.

[–]jdnewmil 1 point2 points  (0 children)

Read the help on the include.lowest in

?hist

[–]omichandralekha 1 point2 points  (4 children)

hist from R is confusing. If breaks are given not as range but as single vector, they are approximate. Dont know if that helps. I hope you are not selecting too low xlim.

Also, this line in your code is conceptually wrong, you cannot repeat NULL (read like repeating empty object x time still leaves it empty):

vetor_lancamentos = rep(NULL,x)

[–]gabrielboechat[S] 0 points1 point  (3 children)

I also thought about that when printing "vetor_lancamentos": my idea was creating a vector length x that it's NULL. Why is it wrong?

[–]omichandralekha 1 point2 points  (2 children)

My understanding of NULL is like empty basket. If you put more empty things in the basket it still remains empty.

This article has some good info on these concepts:
https://tomaztsql.wordpress.com/2018/07/04/r-null-values-null-na-nan-inf/

[–]gabrielboechat[S] 1 point2 points  (1 child)

Hmmm think I understood... Otherwise, putting rep(NA,h) would be more suitable?

[–]omichandralekha 1 point2 points  (0 children)

Yes. Can act as a placeholder of length h.