-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use strict behavior for aweek objects #21
Conversation
This will address #8
This still needs a few tweaks, but this will allow operations like rbind to work.
Still need to add tests for reshaping
- new function stop_if_not_weekday() checks if the incoming integers are weekdays (1--7). - get_wday() is now properly vectorised - as.Date.aweek is now internally documented
Thinking about #20, though
This addresses issues of missing week_starts
This now checks the English weekdays first and then tries the current locale if those fail.
This mechanism is hopefully to avoid the same ambiguity problem that I was trying to solve with c.aweek(). You can create aweek objects from week numbers or characters, but the resulting aweek object should not have a different week_start attribute based on the first element in the vector.
@scottyaz, since you've used aweek in the past, would you mind testing out this version? # install.packages("remotes")
remotes::install_github("reconhub/aweek#21") |
Sure but it may be a few days.
… On May 31, 2019, at 2:37 PM, Zhian N. Kamvar ***@***.***> wrote:
@scottyaz, since you've used aweek in the past, would you mind testing out this version?
# install.packages("remotes")
remotes::install_github("reconhub/aweek#21")
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Thank You! |
Just a quick note before I can look at it more in depth: I thought ISO weeks always start on Monday. Wouldn't a call to |
Yes, ISO weeks all start on Monday, but all aweek objects contain their own |
Installed and tested it. I don't have the time to go through the code really but it looks good to me and I really like the package. |
This PR will fix #20 and fix #8
The aweek package is going through a bit of a change to make things more
consistent. The list of changes can be found in the NEWS.md. Please test out
this code and let me know if you encounter any problems. I plan to release
this the second week of June.
The breaking changes in this release are that it’s no longer possible to
combine aweek objects that have different week_start attributes and factors
no longer coerce factors (but will be converted to characters upon
combination.
In the previous release, I enabled global week_start parameters that allowed
the user to set the week_start variable globally.
Please test this out with:
Below are some highlights:
You can now create aweek objects directly from data frames of week numbers!
You can use numeric week data to create weeks or dates with
get_aweek()
and
get_date()
. By default, they will give you the first week of thecurrent year:
They are vectorised so you can use a data frame with them:
Here you can convert week definitions with different starts to the correct
dates (the week of 2019-03-03).
Or, if you have ISO week formatted strings (YYYY-Www-d), then you can use
as.aweek()
:change_week_start()
will allow you to re-calculate week numbers based on adifferent week_start attribute
factor_aweek()
will aggregate your weeks with levels that span the range.Created on 2019-05-30 by the reprex package (v0.3.0)