In `timetk` ,the result of function `tk_make_weekend_sequence` show nothing

38 Views Asked by At

In timetk ,the result of function tk_make_weekend_sequence show nothing . Anyone can help? Thanks!

library(timetk)

weekends <- tk_make_weekend_sequence(
  start_date = "2017-01-01",
  end_date   = "2017-12-31"
)

weekends

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

To fix this you need to set an English environment for the "LC_TIME"

Sys.setlocale("LC_TIME", "English")

weekends <- tk_make_weekend_sequence(
  start_date = "2017-01-01",
  end_date   = "2017-12-31"
)

weekends

Function tk_make_weekend_sequence uses a lubridate::wday function which work with your local language settings.

ret_tbl <- tibble::tibble(date_sequence = date_sequence) %>%
    dplyr::mutate(weekday = lubridate::wday(date_sequence, label = TRUE)) %>%
    dplyr::filter((weekday == "Sat" | weekday == "Sun"))

The problem is triggered by the filter in the last row. If you don't change "LC_TIME", weekday will be the abbreviation of the day name in your native language.