将列组合成一个整数

时间:2018-01-22 08:16:22

标签: r tidyverse

是否可以使用tidyverse将excel列合并为一个?这就是我现在所拥有的

library(tidyverse)
library(dplyr)
data <- read_excel("chat.xls") %>%
  select(c('Question Answer', Transcript))

1 个答案:

答案 0 :(得分:6)

Tidyr的unite会为你做到这一点。

library(tidyr)

iris %>% unite(New_Column, Sepal.Length,Species,Sepal.Width) 

输出:

> iris %>% unite(New_Column, Sepal.Length,Species,Sepal.Width)
            New_Column Petal.Length Petal.Width
1       5.1_setosa_3.5          1.4         0.2
2         4.9_setosa_3          1.4         0.2
3       4.7_setosa_3.2          1.3         0.2
4       4.6_setosa_3.1          1.5         0.2
5         5_setosa_3.6          1.4         0.2
6       5.4_setosa_3.9          1.7         0.4
7       4.6_setosa_3.4          1.4         0.3
8         5_setosa_3.4          1.5         0.2
9       4.4_setosa_2.9          1.4         0.2
10      4.9_setosa_3.1          1.5         0.1
相关问题