I came across the data/penguins.R
file in the palmerpenguins package. And I was wondering why delayedAssign
was used to basically create an alias penguins
to the cleaned dataset penguins_df
. I understand it won't use up memory until the dataset is called, but isn't it the default of LazyData: true
? Are there any other usage of delayedAssign()
?
I think this is to ensure users with tibble installed gets the tibble awesomeness, and that users without tibble installed do not get any issue.
Digging a bit into the GitHub history, this was added by a PR that provides some context:
This uses a couple of tricks (a delayed binding and an
.R
file in thedata/
directory) to conditionally use tibbles if tibble is installed. I think this gives the best of both worlds — if you're teaching a tidyverse centric course, you'll get tibbles; if you're running in a low dependency environment, you'll get a data frame.
The
penguins
object will never behave differently in a given session; it will either be a pure data frame or a tibble after it is accessed for the first time. It will behave differently in another session if you later install tibble, but I think this should be a relatively rare scenario.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.