I just want some random data to experiment with different prediction models.
My code:
x <- 0
for (i in 1:200)
{
num <- runif(1, 0, 500)
neg <- round(runif(5, -1, 0))
percent <- ((0.01 * runif(1, 1, 10)) * num)
x[i] = num + (neg * percent)
}
The idea is that this should generate 200 points.
num
is a random number between 0 and 500
neg
is either -1 or 1, just to add some flexibility to the random offset (negative or positive offset of a randomly generated point)
percent
is just a random percentage between 1% and 10% of the originally generated random number to either be added or subtracted
Very similar code that I've made in my main language, C#, works very well and generates proper plots. I'm more-or-less trying to port that code.
Whenever I run the above, I get the following errors (a lot of them):
number of items to replace is not a multiple of replacement length
It's triggered on the last line of code in the for loop.
I'd love to be able to fix this. Any help is appreciated. Thank you!