At the moment, the code below is not very reproducible as I am adding the suffix based on column numbers. How would I modify this code to add the suffix to all columns beginning with "rs" instead of using column numbers?
# make data
df <- data.frame(y1 = rbinom(100, 1, 0.5), y2 = rbinom(100, 1, 0.3), y3 = rbinom(100, 1, 0.2), y4 = rbinom(100, 1, 0.22),
rs1 = rnorm(100), rs2 = rnorm(100), rs3 = rnorm(100),
rs4 = rnorm(100), rs5 = rnorm(100), rs6 = rnorm(100))
# add suffix to column names beginning with rs
colnames(df)[5:10] <- paste(colnames(df)[5:10], "C", sep = "_")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…