→ celestialgod: mutate_(df, .dots = paste0("x", 1:4, "_", 1, 03/17 19:09
→ celestialgod: "+x", 1:4, "_", 2)) 03/17 19:09
→ celestialgod: df是你的data.frame 03/17 19:09
→ celestialgod: mutate_ 先library(dplyr) 03/17 19:10
→ celestialgod: mutate_(x, .dots = paste0("paste(x", 1:4, 03/17 19:11
→ celestialgod: "_", 1, ",x", 1:4, "_", 2, ",sep='/')")) 03/17 19:11
→ celestialgod: x是你的data.frame 03/17 19:11
→ celestialgod: 前三推打太快,忘記改成你要你的格式,抱歉 03/17 19:12
→ celestialgod: mutate_之後 再重新命名跟選你需要的column出來即可 03/17 19:12
→ swedrf0112: t(apply(data,1,function(x) 03/17 19:13
→ swedrf0112: paste0(x[seq(1,length(x),2)],"/" 03/17 19:13
→ swedrf0112: ,x[seq(2,length(x),2)]))) 03/17 19:14
→ swedrf0112: data放你的資料~~ 03/17 19:15
→ celestialgod: s大,第一個seq應該從3開始,而非1,第一個是id。 03/17 19:24
→ swedrf0112: 3Q!! 沒看到 修改一下 第一個seq(2,length(x),2) 03/17 19:33
→ swedrf0112: 第二個seq(3,length(x),2) 03/17 19:33
推 andrew43: 親愛的板友,如果要推多次連續code,建議直接回文喔。 03/17 20:41
→ yaohwei: 謝謝各位,成功了 03/18 08:53