Learn R Programming

⚠️There's a newer version (0.6.3) of this package.Take me there.

padr

padr is an R package that assists with preparing time series data. It provides two main functions that will quickly get the data in the format you want. When data is observed on too low a level, thicken will add a column of a higher interval to the data frame, after which the user can apply the appropriate aggregation. When there are missing records for time points where observations were absent, pad will automatically insert these records. A number of fill_ functions help to subsequently fill the missing values.

Usage

coffee <- data.frame(
  time_stamp =  as.POSIXct(c(
    '2016-07-07 09:11:21', '2016-07-07 09:46:48',
    
    '2016-07-09 13:25:17',
    '2016-07-10 10:45:11'
  )),
  amount = c(3.14, 2.98, 4.11, 3.14)
)

coffee %>%
  thicken('day') %>%
  dplyr::group_by(time_stamp_day) %>%
  dplyr::summarise(day_amount = sum(amount)) %>%
  pad() %>%
  fill_by_value(day_amount, value = 0) %>%
  ggplot2::ggplot(ggplot2::aes(time_stamp_day, day_amount)) +
    ggplot2::geom_line()

More information

See the the general introduction Vignette for more examples. The implementation details Vignette describes how padr handles different time zones and daylight savings time.

Copy Link

Version

Install

install.packages('padr')

Monthly Downloads

11,553

Version

0.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Edwin Thoen

Last Published

January 17th, 2017

Functions in padr (0.1.0)

fill_by_prevalent

Fill missing values by the most prevalent nonnmissing value.
fill_by_function

Fill missing values by a function of the nonmissings.
pad

Pad the datetime column of a data frame.
thicken

Add a variable of a higher interval to a data frame.
get_interval

Get the interval of a datetime variable.
fill_by_value

Fill missing values by a single value.