tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
531 stars 49 forks source link

The help of the as_tibble should explain different ways to specify monthly, daily data #176

Closed paulrougieux closed 4 years ago

paulrougieux commented 4 years ago

The FAQ explains the need to use the yearmonth class:

"It is unclear for this case to tell if it’s daily data with implicit missingness or it’s monthly data. If using Date underlying monthly data, each month could range from 28 to 31 days, which isn’t regularly spaced. But class yearmonth puts emphasis on 12 months per year, which is clearly regularly spaced and the accurate representation for aggregations over months. "

Usage illustrated in this example:

mth <- make_date("2018") + months(0:3)
tsibble(mth = yearmonth(mth), index = mth)

But this is confusing to a new user wanting to convert an existing data frame with the as_tsibble function. The different ways to specify monthly, daily data could be explained as different examples in the help of the as_tsibble function.

Clearly the yearmonth class is used in the examples in the help page of the as_tsibblefunction, so it probably just needs an introduction, explanation of the difference with a standard POSIXct, format.

tbl2 <- tibble(
  mth = rep(yearmonth("2017-01") + 0:9, 3),
  group = rep(c("x", "y", "z"), each = 10),
  value = rnorm(30)
)
earowang commented 4 years ago

Thanks. Hope it improved a bit.