I'm entry user of R studio.
How to write in Rstudio
Computer selects one number from 1 to 3 using "sample()", and I would like to input it as x.
User selects one number from 1 to 3 using "menu()" , and I would like to input it as y.
I'm entry user of R studio.
How to write in Rstudio
Computer selects one number from 1 to 3 using "sample()", and I would like to input it as x.
User selects one number from 1 to 3 using "menu()" , and I would like to input it as y.
Think this might do it.
x <- round(runif(1L, min = 1L, max = 3L))
y <- menu(1:3)
This won't choose a number 1 to 3 with equal probability and x will be a value of 1 25% of the time, 2 50% of the time, and 3 25% of the time. Instead, use the sample function
x <- sample(3, 1)
y <- menu(1:3)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.