最后两个语句用任何一个都可。
- library(lubridate) #use year
- library(dplyr) #use filter and mutate
- library(stringr) #use str_detect
- come<-read.table("come.txt",sep=",",header = T)
- come%>%filter(str_detect(Date,pattern="2016"))
- come%>%mutate(year=year(Date))%>%filter(year==2016)