【发布时间】:2021-09-11 19:05:15
【问题描述】:
我在数据框中有一列,old_df。
示例行如下所示:
data
trying URL 'https://maps.googleapis.com/maps/api/streetview?&location=13.5146367326733,100.380686367492&size=8000x5333&heading=0&fov=90&pitch=0&key='Content type 'image/jpeg' length 59782 bytes (58 KB)
downloaded 58 KB
使用stopwords,我删除了我不想要的词,并留下:
data
?&13.5146367326733,100.380686367492
?&13.5162026732673,100.66581378616
stopwords = c('trying',
'URL',
"'",
'&',
'location=',
'https://maps.googleapis.com/maps/api/streetview',
'size=8000x5333',
'heading',
'=0&fov=90&pitch=0&key=',
'Content',
'type',
'image/jpeg',
'length',
'bytes',
'KB')
require('tm')
new_df <- as.data.frame(removeWords(old_df$data, stopwords))
但是,?& 仍保留在数字之前的 data 列中(我不想要)。我尝试在stopwords 中包含?、& 和?&,但它们仍然存在。任何想法如何删除它们?
确实,当我在stopwords 中包含上述组合时,我得到了错误:
PCRE pattern compilation error 'quantifier does not follow a repeatable item' at '?|&|')\b'
【问题讨论】:
标签: r dataframe stop-words