R 使用分隔符将一行分隔为多行

R 使用分隔符将一行分隔为多行,r,R,将数据帧数据放入一行,如下所示: data.frame(text = c("in this line ???? another line and ???? one more", "more lines ???? another row") 使用分隔符???分隔成多行????。这里是预期输出 data.frame(text = c("in this line", "another line and", "one more", "more lines", "another row") 这是一个基

将数据帧数据放入一行,如下所示:

data.frame(text = c("in this line ???? another line and ???? one more", "more lines ???? another row")
使用分隔符???分隔成多行????。这里是预期输出

data.frame(text = c("in this line", "another line and", "one more", "more lines", "another row")

这是一个基本的R解决方案

dfout <- data.frame(text = unlist(strsplit(as.character(df$text),split = " \\?{4} ")))

如果您执行
sep='??'
和add
fixed=TRUE
,它将通过绕过regex显著提高效率engine@Sotos谢谢你的信息,很高兴知道
dfout <- data.frame(text = unlist(strsplit(as.character(df$text),split = " ???? ", fixed = TRUE)))
> dfout
              text
1     in this line
2 another line and
3         one more
4       more lines
5      another row