Sorry for this simple question, I haven't found a fitting solution for this in my search. I'd like to create a new column in my data frame and fill it with random numbers between 1 to 100 (can repeat).
Below is the code I'm currently using,
data$newrow <- rep(1:100,replace=T, nrow(data))
I receive this error:
Error in `$<-.data.frame`(`*tmp*`, "newrow", value = c(1L, 2L, :
replacement has 2088800 rows, data has 20888`
Can you help me fix my code?
data$newrow <- sample(100, size = nrow(data), replace = TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With