简体   繁体   English

使用R将词组分解为单词

[英]Splitting phrases into words using R

I have a search queries report from Google Analytics which gives me the phrases on which a user searched. 我有一个来自Google Analytics(分析)的搜索查询报告,其中提供了用户进行搜索的词组。 I have it in a dataframe, the first column of which looks a bit like this: 我将其放在一个数据框中,其第一列看起来像这样:

search.queries
1   the quick
2   brown fox jumps
3   over the 
4   lazy
5   dog

Ideally I would very much like it in the form: 理想情况下,我非常喜欢以下形式:

words
1   the 
2   quick
3   brown
4   fox
...

Any help would be very much appreciated 任何帮助将不胜感激

Kind Regards 亲切的问候

G G

Just do splitting. 只是做分裂。

> df <- data.frame(names = c("the quick","brown fox", "over the lazy", "dog"))
> data.frame(names = unlist(strsplit(as.character(df$names), "\\s+")))
  names
1   the
2 quick
3 brown
4   fox
5  over
6   the
7  lazy
8   dog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM