0
我正在尋找一種方法來將列「col1」複製x次,並將每個這樣的副本從一個字符向量附加到x個字符串中。例如:造成動態複製後綴爲R的數據框列R
df <- data.frame(col1 = c(1,2,3,4,5))
suffix <- c("a", "b", "c")
:
df_suffix <- data.frame(col1 = c(1,2,3,4,5), col1_a = c(1,2,3,4,5), col1_b = c(1,2,3,4,5), col1_c = c(1,2,3,4,5))
col1 col1_a col1_b col1_c
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5