r将列表列转换为字符向量,其中列表是字符 [英] r-convert list column into character vector where lists are characters
本文介绍了r将列表列转换为字符向量,其中列表是字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将列表转换为单个字符值,或者基本上是从此开始:
I'm trying to convert a list into a single character value, or basically go from this:
test <- data.frame(a = c(1,1,1,2,2,2), b = c("a", "b", "c", "d", "e", "f" )) %>%
group_by(a) %>% summarise(b = list(b))
对此:
test <- data.frame(a = c(1,2), b = c("a, b, c", "d, e, f" ))
推荐答案
在这里:
test %>%
mutate(b = sapply(b, toString))
## A tibble: 2 x 2
# a b
# <dbl> <chr>
#1 1. a, b, c
#2 2. d, e, f
这篇关于r将列表列转换为字符向量,其中列表是字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文