I would like to randomly replace values in my data frame, so that I would have 3 names with NA values, instead of having just one.
Names <- c("Tom", "Alex", "James", "John", "Wayne", "Harry")
a <- c(1,3,6,8, NA, 5)
b <- c(3,6,9,1, NA,1)
c <- c(7,3,1,6,NA,6)
d <- c(1,4,7,2,NA,8)
data <- data.frame(Names,a,b,c,d)
I've managed to get this:
newdata <- data
for (j in 1){
for(i in 2:5){
newdata[j, i] <- NA
}}
But it replace values from the first row. Could anyone please help me and tell me how can I make it replace values in random rows?
Aucun commentaire:
Enregistrer un commentaire