Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将单词之间的空格减少到1_R_Text_Text Mining_Gsub - Fatal编程技术网

R 将单词之间的空格减少到1

R 将单词之间的空格减少到1,r,text,text-mining,gsub,R,Text,Text Mining,Gsub,我有一个facebook帖子列表,我已经从中删除了符号。现在,我在文本之间留下了空白-2个或更多的空格,我想对其进行压缩。如何删除多余的空格,使单词之间只有一个空格?此外,如何删除文本中独立的所有大写字母 > head(posts) [1] "Syntel Recruitment Drive in this week for FRESHERS New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualific

我有一个facebook帖子列表,我已经从中删除了符号。现在,我在文本之间留下了空白-2个或更多的空格,我想对其进行压缩。如何删除多余的空格,使单词之间只有一个空格?此外,如何删除文本中独立的所有大写字母

> head(posts)
[1] "Syntel Recruitment Drive in this week for FRESHERS   New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualification   Any Graduate B E B Tech MCA M E M Tech Syntel Registration Link"            
[2] "Dont Miss This Opportunity to be get placed in one of the best MNC companies in the world   eBay freshers this week of January 2016  Qualification   Any Graduate Can Apply   eBay Registration Link"            
[3] "Recent Pass Outs with 55  or More are eligible to Apply in  Wipro   Go to the Updated Link for  LastDay Reference Drive  Jan 2016  Apply Link for  Fresher  Referral  Apply Link"                                
[4] "Robert Bosch Recruitment Drive in this week for FRESHERS   New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualification   Any Graduate B E B Tech MCA M E M Tech Robert Bosch Registration Link"
[5] "Mega  JOB  OPENINGS  OF  THE  YEAR  Mphasis Recruitment for FRESHERS January 2016 Qualification   BE  B Tech  B Sc  BCA  Any Graduates  MCA  MBA  ME  M Tech  Post Graduates  Mphasis Registration Link"         
[6] "TRIGENT Recruitment Drive in this week for FRESHERS   New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualification   Any Graduate B E B Tech MCA M E M Tech Trigent Registration Link"  


> dput(head(posts))
c("Syntel Recruitment Drive in this week for FRESHERS   New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualification   Any Graduate B E B Tech MCA M E M Tech Syntel Registration Link", 
"Dont Miss This Opportunity to be get placed in one of the best MNC companies in the world   eBay freshers this week of January 2016  Qualification   Any Graduate Can Apply   eBay Registration Link", 
"Recent Pass Outs with 55  or More are eligible to Apply in  Wipro   Go to the Updated Link for  LastDay Reference Drive  Jan 2016  Apply Link for  Fresher  Referral  Apply Link", 
"Robert Bosch Recruitment Drive in this week for FRESHERS   New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualification   Any Graduate B E B Tech MCA M E M Tech Robert Bosch Registration Link", 
"Mega  JOB  OPENINGS  OF  THE  YEAR  Mphasis Recruitment for FRESHERS January 2016 Qualification   BE  B Tech  B Sc  BCA  Any Graduates  MCA  MBA  ME  M Tech  Post Graduates  Mphasis Registration Link", 
"TRIGENT Recruitment Drive in this week for FRESHERS   New Registration Link 2016 for 2013 2014 2015 Passout Graduates Qualification   Any Graduate B E B Tech MCA M E M Tech Trigent Registration Link"
)

使用
gsub
,您可以尝试

posts <- gsub(" +", " ", posts)
帖子