tibble::tibble(
col1 = c("A","","C","",""),
col2 = c("string1 part 1","string1 part 2",
"string2 part 1", "string2 part 2",
"string3"),
col3 = c(1, "", 2, "", 3)
)
我想合并中的行col2
,获得一个没有像这样的空字符串的小标题
tibble::tibble(
col1 = c("A","C",NA),
col2 = c("string1 part 1 string1 part 2", "string2 part 1 string2 part 2", "string3"),
col3 = c(1,2,3)
)
# A tibble: 3 x 3
col1 col2 col3
<chr> <chr> <dbl>
1 A string1 part 1 string1 part 2 1
2 C string2 part 1 string2 part 2 2
3 NA string3 3
正如我在其他答案中发现的那样,分组似乎不是一个选项,而我没有任何参考列