我有这个数据框:
df <- structure(list(letters = c("A", "B", "C", "D"), Number = 1:4,
Info = c("additionalinfo", "additionalinfo", "additionalinfo",
"additionalinfo")), class = "data.frame", row.names = c("1",
"2", "3", "4"))
letters Number Info
1 A 1 additionalinfo
2 B 2 additionalinfo
3 C 3 additionalinfo
4 D 4 additionalinfo
我尝试添加一个新列,将两列与软中断或换行符组合起来:
df %>%
mutate(answer = paste(Number, Info, sep = " \n" ))
期望的输出:
背景:在这个项目中,从数据框列中随机取一个测验问题的错误答案,而不是手动做我想用软中断或换行符添加答案