I’m just starting to learn R, and my assignment was to create a vector of 10000 values with normal distribution, mean = 0 and sd = 100. Which I did.
x <- rnorm(10000, mean = 0, sd = 100)
But now I’m asked to introduce values between 500 and 700 at 1000 random positions in that vector.
Can anyone help me?
If you mean to replace 1000 elements in the
xvector with values between 500 and 700, you first need to generate these 1000 elements:I am assuming here that random values are uniformly between 500 and 700.
Then you need to select places to put these values in:
Finally, replace the values at these places:
Finally, to see the results of your action:
It should look like: