小编Nic*_*ick的帖子

有条件地连接多行字符串

我从 PDF 中提取了多个表格,其中包含多行字符串。我使用了 tabulizer 包中的 extract_table() 函数,唯一的问题是字符串作为单独的行导入。

例如

action <- c(1, NA, NA, 2, NA, 3, NA, NA, NA, 4, NA)

description <- c("a", "b", "c", "a", "b", "a", "b", "c", "d", "a", "b")

data.frame(action, description)

       action description
1       1           a
2      NA           b
3      NA           c
4       2           a
5      NA           b
6       3           a
7      NA           b
8      NA           c
9      NA           d
10      4           a
11     NA           b
Run Code Online (Sandbox Code Playgroud)

我想连接字符串,使它们显示为相同的元素,例如:

  action description
1      1       a b c
2 …
Run Code Online (Sandbox Code Playgroud)

string r string-concatenation

5
推荐指数
1
解决办法
1298
查看次数

标签 统计

r ×1

string ×1

string-concatenation ×1