【发布时间】:2018-08-29 22:55:04
【问题描述】:
我有一个需要清理的字符向量。具体来说,我想删除“投票”一词之前的数字。请注意,数字用逗号分隔千位,因此更容易将其视为字符串。
我知道 gsub("*. Votes","", text) 会删除所有内容,但我该如何删除数字?另外,如何将重复的空格折叠成一个空格?
感谢您提供的任何帮助!
示例数据:
text <- "STATE QUESTION NO. 1 Amendment to Title 15 of the Nevada Revised Statutes Shall Chapter 202 of the Nevada Revised Statutes be amended to prohibit, except in certain circumstances, a person from selling or transferring a firearm to another person unless a federally-licensed dealer first conducts a federal background check on the potential buyer or transferee? 558,586 Votes"
【问题讨论】: