【发布时间】:2016-06-13 03:09:42
【问题描述】:
我需要从具有这些性质的值的向量中提取开始年份和结束年份。
yr<- c("June 2013 – Present (2 years 9 months)", "January 2012 – June 2013 (1 year 6 months)","2006 – Present (10 years)","2002 – 2006 (4 years)")
yr
June 2013 – Present (2 years 9 months)
January 2012 – June 2013 (1 year 6 months)
2006 – Present (10 years)
2002 – 2006 (4 years)
我期待这样的输出。有人有建议吗?
start_yr end_yr
2013 2016
2012 2013
2006 2016
2002 2006
【问题讨论】:
-
gsub "present" 与 2016 并提取四位数字。试试看