Working with Dates and Times in R
Charlotte Wickham
Instructor
date,max_temp,min_temp,mean_temp,mean_rh,events,cloud_cover
2007-9-1,60,51,56,75,NA,4
2007-9-2,60,53,56,82,Rain,4
2007-9-3,57,51,54,78,NA,6
2007-9-4,64,50,57,80,Rain,6
2007-9-5,53,48,50,90,Rain,7
year,month,mday,time,temperature,weather,conditions,events,humidity,date_utc
2016,1,1,00:00:00,68,Clear,Clear,NA,68,2015-12-31T11:00:00Z
2016,1,1,00:30:00,68,Clear,Clear,NA,68,2015-12-31T11:30:00Z
2016,1,1,01:00:00,68,Clear,Clear,NA,73,2015-12-31T12:00:00Z
2016,1,1,01:30:00,68,Clear,Clear,NA,68,2015-12-31T12:30:00Z
2016,1,1,02:00:00,68,Clear,Clear,NA,68,2015-12-31T13:00:00Z
make_date(year = 2013, month = 2, day = 27)
"2013-02-27"
make_datetime(year, month, day, hour, min, sec)
for datetimes
mutate()
- add new columns (or overwrite old ones)filter()
- subset rowsselect()
- subset columnsarrange()
- order rowssummarise()
- summarise rowsgroup_by()
- useful in conjuction with summarise()
# Without the pipe: nested functions summarise(group_by(filter(releases, major == 3), minor), n = n())
# With pipe: more linear releases %>% filter(major == 3) %>% group_by(minor) %>% summarise(n = n())
Working with Dates and Times in R