📅  最后修改于: 2022-03-11 14:59:01.648000             🧑  作者: Mango
for(i in 1:3) { # Head of for-loop
new <- rep(i, nrow(data)) # Create new column
data[ , ncol(data) + 1] <- new # Append new column
colnames(data)[ncol(data)] <- paste0("new", i) # Rename column name
}