padr v0.5.0


Monthly downloads



Quickly Get Datetime Data Ready for Analysis

Transforms datetime data into a format ready for analysis. It offers two core functionalities; aggregating data to a higher level interval (thicken) and imputing records where observations were absent (pad).



Build Status CRAN\_Status\_Badge

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.


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)
## # A tibble: 4 × 2
##   time_stamp_day day_amount
##           <date>      <dbl>
## 1     2016-07-07       6.12
## 2     2016-07-08       0.00
## 3     2016-07-09       4.11
## 4     2016-07-10       3.14

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.

Functions in padr

Name Description
pad_cust Pad with a custom spanning
span_time Wrapper around seq.POSIXct.
subset_span Subset a spanned datetime vector
center_interval Shift to the middle of each interval
closest_weekday Retrieve the closest given weekday
fill_by_prevalent Fill missing values by the most prevalent nonmissing value
fill_by_function Fill missing values by a function of the nonmissings
thicken_cust Thicken with a custom spanning
pad_int Pad the integer column of a data frame
fill_by_value Fill missing values by a single value
pad Pad the datetime column of a data frame
get_interval Get the interval of a datetime variable
format_interval Make a period character vector
emergency Emergency Calls for Montgomery County, PA
coffee Coffee Data Set
span_around Span an equally spaced vector around a datetime variable
span_date Wrapper around seq.Date.
thicken Add a variable of a higher interval to a data frame
No Results!

Vignettes of padr

No Results!

Last month downloads


Type Package
License MIT + file LICENSE
Encoding UTF-8
LazyData true
RoxygenNote 6.1.1
LinkingTo Rcpp
VignetteBuilder knitr
ByteCompile true
NeedsCompilation yes
Packaged 2019-06-11 13:00:11 UTC; edwinthoen
Repository CRAN
Date/Publication 2019-06-11 13:20:03 UTC

Include our badge in your README