r - Creating a new column filled with random numbers -


sorry simple question, haven't found fitting solution in search. i'd create new column in data frame , fill random numbers between 1 100 (can repeat).

below code i'm using,

data$newrow <- rep(1:100,replace=t, nrow(data))

i receive error:

error in `$<-.data.frame`(`*tmp*`, "newrow", value = c(1l, 2l,  :    replacement has 2088800 rows, data has 20888` 

can me fix code?

data$newrow <- sample(100, size = nrow(data), replace = true) 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -