📅  最后修改于: 2022-03-11 15:00:24.181000             🧑  作者: Mango
for(i in 1:5) { # Head of for-loop
new_col <- rep(i, 3) # Creating new variable
data[ , i] <- new_col # Adding new variable to data
colnames(data)[i] <- paste0("Col_", i) # Renaming new variable
}