如何使用 base 在第一个逗号上有效地拆分以下字符串?
x <- "I want to split here, though I don't want to split elsewhere, even here."
strsplit(x, ???)
期望的结果(2 个字符串):
[[1]]
[1] "I want to split here" "though I don't want to split elsewhere, even here."
先感谢您。
编辑:没想到要提这个。这需要能够推广到一列,这样的字符串向量,如:
y <- c("Here's comma 1, and 2, see?", "Here's 2nd sting, like it, not a lot.")
结果可以是两列或一个长向量(我可以取每个其他元素)或每个索引([[n]])有两个字符串的字符串列表。
对缺乏明确性表示歉意。