gpt4 book ai didi

r - 将列表组合成 R 中的单个列表

转载 作者:行者123 更新时间:2023-12-05 08:45:17 24 4
gpt4 key购买 nike

我有单独的列表:

1. $text = "I love this product"
2. $text = "Amazing service and care given, will visit once again"
3. $text = "Love this product!!"

我如何将所有列表合并为一个列表,这样:

$text = ["I love this product", "Amazing service and care given, will visit once again", "Love this product!!"]

我想保存在一个数据框中

Product Reviews 
A ["I love this product", "Amazing service and care given, will visit once again", "Love this product!!"]
B ["I ......."]
列表的

dput:

list(list(text="I love this product"),
list(text="Amazing service and care given, will visit once again"),
list(text="Love this product!!"))

当我使用 cbind 时,它返回:

Reviews
"I love this product"
"Amazing service and care given, will visit once again"
"Love this product!!"

不是我想要的

最佳答案

这里显而易见的解决方案是简单地取消列出您的列表:

list(text = unlist(mylist, use.names = FALSE))
#> $text
#> [1] "I love this product"
#> [2] "Amazing service and care given, will visit once again"
#> [3] "Love this product!!"

reprex package 创建于 2022-07-31 (v2.0.1)

关于r - 将列表组合成 R 中的单个列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73182819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com