I am trying to run a routine in R, involving replicating a random experiment. I encountered errors with the dimension of the output, which led me to discover the following peculiarity:
length(replicate(100 - 100*8 / 10, 4))
# 20
length(replicate(100 *(1- 8/ 10), 4))
# 19
As a sanity check, I ran the lines of code to make sure that the expressions in the first argument of replicate
produced the same output.
100 - 100*8 / 10
# 20
100 *(1- 8/ 10)
# 20
I was wondering if people are experiencing the same issue. What I really want to know is, why does this happen?
Note: I am aware of the difference between rep
and replicate
, and my routine requires the latter, not the former.