【问题标题】:combining columns into one in tidyverse在 tidyverse 中将列合并为一个
【发布时间】:2018-01-22 08:16:21
【问题描述】:

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

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

【问题讨论】:

  • 相同的数据框?

标签: r tidyverse


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-12-28
    • 2015-02-22
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2016-01-10
    • 1970-01-01
    • 2014-04-01
    相关资源
    最近更新 更多