- Notifications
You must be signed in to change notification settings - Fork9
SUpporting GRaphics with R for ANalysing Time Series
earowang/sugrrants
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The goal ofsugrrants is to provide supporting graphs with R foranalysing time series data. It aims to fit into thetidyverse andgrammar of graphics framework for handling temporal data.
You could install the stable version on CRAN:
install.packages("sugrrants")
You could also install the development version from Github using:
# install.packages("remotes")remotes::install_github("earowang/sugrrants")
The fully-fledged faceting calendarfacet_calendar()
unlocksday-to-day stories.
library(dplyr)library(sugrrants)hourly_peds %>% filter(Date< as.Date("2016-05-01")) %>% ggplot(aes(x=Time,y=Hourly_Counts,colour=Sensor_Name))+ geom_line()+ facet_calendar(~Date)+# a variable contains dates theme_bw()+ theme(legend.position="bottom")
On the other hand, theframe_calendar()
provides tools forre-structuring the data into a compact calendar layout, without usingthe faceting method. It is fast and light-weight, although it does notpreserve the values.
p<-hourly_peds %>% filter(Sensor_ID==9,Year==2016) %>% mutate(Weekend= if_else(Day%in% c("Saturday","Sunday"),"Weekend","Weekday")) %>% frame_calendar(x=Time,y=Hourly_Counts,date=Date) %>% ggplot(aes(x=.Time,y=.Hourly_Counts,group=Date,colour=Weekend))+ geom_line()+ theme(legend.position="bottom")prettify(p)
This package is part of the project—Tidy data structures and visualmethods to support exploration of big temporal-contextdata,which has been participated in Google Summer of Code 2017 (gsoc), forRproject for statistical computing.
A new functionframe_calendar()
[hereandhere]in thesugrrants package has been developed and documented forcalendar-based graphics. I have also written a vignette[sourceandreaderview],which introduces and demonstrates the usage of theframe_calendar()
function.Many unittestshave been carried out to ensure the expected performance of thisfunction. The function implements non-standard evaluation and highlightsthetidy evaluation in action. The initialrelease (v0.1.0) of the package has been published onCRAN during the gsocsummer time.
I have initialised a new R packagetsibble for tidy temporaldata, as part of the project. Thetsibble()
function constructs a newtbl_ts
class for temporal data, and theas_tsibble()
helps toconvert a fewts
objects into thetbl_ts
class. Some key verbs(generics) from thedplyr package, such asmutate()
,summarise()
,filter()
, have been defined and developed for thetbl_ts
data class. Thetsibble package was highly experimentalover the period of the gsoc[commits],and these functions are very likely to be changed or improved in thefuture.
A new packagerwalkr has beencreated and released onCRAN during the gsocsummer. This package provides API to Melbourne pedestrian sensor dataand arrange the data in tidy temporal data form. Two functions includingwalk_melb()
andshine_melb()
,have been written and documented as the v0.1.0 and v0.2.0 releases onCRAN. The majority of the code for the functionrun_melb()
has been done, but the interface needs improving after the gsoc.
The acronym ofsugrrants isSUpportingGRaphs withR forANalysingTimeSeries, pronounced as “sugar ants” that are aspecies of ant endemic to Australia.
Please note that this project is released with aContributor Code ofConduct.By participating in this project you agree to abide by its terms.
About
SUpporting GRaphics with R for ANalysing Time Series