Skip to content
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

Merge pkg into masters #24

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open

Merge pkg into masters #24

wants to merge 69 commits into from

Conversation

DavZim
Copy link
Collaborator

@DavZim DavZim commented Nov 16, 2018

No description provided.

DavZim and others added 30 commits August 22, 2018 04:19
this makes it easier to differentiate between the join-related and the (coming) tidyr-related functions that have similar goals
-id1, -id2 work, id1:id2 does not (yet)
- Import packages from tidyverse
- Set global imports in zzzz-package.R
- Import pipe and tidyeval
- Update authors
- Downgrade version to 0.0.1.9000
- Change license to MIT
- TODO: Internal package qualifications still needed, e.g. dplyr::row_numbers()
if printed it will still call animate, but gives the user more flexibility about animation factors (such as times etc)
Uses the algorithm mentioned at https://stackoverflow.com/a/3943023/2022615 based on the luminance of the background color to determine black or white text. The threshold favored black text in a way that didn't look good with our plots, so I increased the threshold from 0.179 to 0.333.
Adds a few additional dplyr functions to the package imports, in particular: slice, data_frame, and row_number.
Currently only used for setting global text and title font sizes, but can be extended to other options that we may wish to set for more than one plot. For fonts, we now provide `set_font_size()` that can be used to set text and title sizes across all subsequent animations. Includes internal getter functions get_{text|title}_size().
Sets figure output to man/figures/tidyexplain- and ensures that all R chunks that output figures are named. This gives a collection of animations and static images with reasonable names ready for download and use.
Changed name of set_text_color() to choose_text_color() to avoid confusion with the global option setter functions, e.g. set_text_size(). Updated tests to reflect modified threshold.
animate_join() now lives in animate_join.R with the other animate_join_ functions. These all use rlang::enquo() to capture their arguments so that animate_join() can print the variable name in the plot title.
And change Long/Wide to lowercase to reflect that they are both variables names and a description of the state of the data.
Adds get_input_text() that can be used to get the literal variable name and make_named_data() that creates a list with the input data frames. This second one is necessary because the inputs may be quosures and we need to get the underlying data frames. Default names are $x and $y.
@DavZim
Copy link
Collaborator Author

DavZim commented Nov 16, 2018

Somehow I cannot push my local master to the repository. Is it possible that you merge the branches in this PR?

@krlmlr
Copy link

krlmlr commented Nov 26, 2018

Can you push your local master under a different name, so that we can sort it out? Some changes from this branch are in conflict with the main master.

# Make sure working copy is clean
git checkout -b master-davzim master
git push -u origin HEAD

To bring local master in sync with this master, you can then do:

# Make sure working copy is clean
git checkout master
git reset --hard origin/master

This assumes that the remote that corresponds to this repo is called origin, adapt as necessary. (Sometimes it's called upstream or perhaps gadenbuie .)

@DavZim
Copy link
Collaborator Author

DavZim commented Nov 26, 2018

I have tried that but I am not sure if that was correct. The merge has also introduced old files from the master branch.
Currently the pkg branch consists of the package version including working joins, sets, and tidyr functionality. I.e., renaming (?) pkg as master should do the trick.

@krlmlr
Copy link

krlmlr commented Nov 26, 2018

The master-davzim branch looks like master where the pkg branch has been merged into. I see two approaches now:

  1. Open a PR from master-davzim to master, this should be mergeable without conflicts and show the relevant differences. We can review and double-check if the changes are intended.

  2. Backport the missing commits from master into pkg (this might be the easier approach if you can confirm that most of these commits are already included in pkg). Below is the output of git log origin/pkg..origin/master --oneline:

    fe4d4b0 (origin/master, origin/HEAD, krlmlr/master, master) Add CODEOWNERS
    f92a350 Fix Fix tidyr spread/gather static image #9 by removing tidyr spread/gather grouped image
    69cb816 Remove border and use width = height = 0.9 for tiles
    adad81e Merge pull request Readme updates #8 from gadenbuie/readme-updates
    01f9450 Close tidyr :: spread() and gather() #1 with PR Add tidyr::spread and tidyr::gather #7 add tidyr spread and gather
    e2011de Requires cowplot
    a6dfac1 📚 Add text to readme for each section
    4304ec6 Re-order sections (background/learning up top)
    7848969 Add links to level 2 headers
    949d9ce Add tidyr::spread and tidyr::gather

@DavZim
Copy link
Collaborator Author

DavZim commented Nov 26, 2018

I am a bit unsure how to resolve this exactly.
We have worked on the pkg branch and neglected the master branch until the pkg was finished...
Now the pkg branch replaces the master branch entirely. That is, the changes and commits in the master branch that are not in the pkg branch are not needed anymore, with the exception of fe4d4b0.

The master-davzim branch is obsolete I think, that is, the pkg branch holds everything we need.

@krlmlr
Copy link

krlmlr commented Nov 26, 2018

Then:

# Make sure working copy is clean
git checkout pkg
git cherry-pick --no-edit fe4d4b0
git merge master -X ours
git push

This will allow merging this PR.

@DavZim
Copy link
Collaborator Author

DavZim commented Nov 26, 2018

That looks good! (On a sidenote: Thanks for the help and your time!)
But we are still depending on a code review right?

@krlmlr
Copy link

krlmlr commented Nov 26, 2018

You're welcome.

The technical challenges are resolved, we need approval from Garrick now.

@gadenbuie
Copy link
Owner

Sorry all that it's taken me a while to get to this. I had quite a bit going on around our recent holiday and didn't have time to get to this. I should be able to move this forward this week.

Personally, I prefer the master/dev branch style (along the lines of this git branching model), where the master branch contains complete features and user-ready code. In this case I was treating pkg as the dev branch.

Before we merge pkg to master, I'd like to survey the current state of the package branch to get a better sense of what's working and what's not quite ready yet. I'm happy to do this, but it might take me a little bit so @DavZim if you'd like to help out that would be appreciated.

theme_env seems to have been retired from ggplot, replaced with theme_void
before the additional arguments such as color_header  = "black" would trigger a warning that the argument is not recognised. Now the color arguments passed to add_color_join
before saving, the function animate needs to be called
more in line with set_text_* functions
helpful if there is wide text
@DavZim
Copy link
Collaborator Author

DavZim commented Nov 27, 2018

No worries, my simulations are running in the background so I have some time to look into this.

My conclusion is below. I also tweaked some minor things, added more options (color and sizes of cells), and updated both the Readme and the images

The status quo (branch master) allows the following functions:

  • mutating and filtering joins
  • set operations
  • tidy data operations

each function is script based and does not allow for different datasets (i.e., other variable names etc) as parameters are hard coded.

This branch (branch pkg) refactors the code and introduces the package layer, while keeping the functionality. I.e., the same functions can be animated with similar results, the differences come from small design choices.

Furthermore, we introduce the following features in pkg:

  • similar to the underlying functions tidyverse functions, we use rlang for non-standard evaluation, increasing the usability (e.g., to animate the base function left_join(df1, df2, by = "var1") the call becomes animate_left_join(df1, df2, by = "var1")). Where possible all functionality of the base functions is supported (see below for some examples where its not working).
  • using anim_options() the user gains the freedom to specify many small animation details such as font size, family, or animation speed. The options can be set for the current session using the functions set_font_size() and set_anim_options(). If only one animation/pictures should be affected by the option, the user can choose to use the anim_opts = anim_options(...) argument or directly supply the options (animate_left_join(..., cell_width = 2)). The full list of possible options is described in ?anim_options (including the changes from my last commits about colors and cell sizes).

The animations/pictures for the users that do not wish to compile the graphics by themselves is updated to contain the new versions of the operations (in the folder images).

My conclusion, the pkg-branch is working good. Some user-facing information could be included in the readme to point the user to the features she can tweak, but our documentation in the package covers everything I found.
Another issue that we might want to address at one point, is that our errors are not telling enough, e.g., animate_gather(wide, key = "person", value = "sales") instead of animate_gather(wide, key = "person", value = "sales", -year) (missing -year), returns the error Error: Columns .key_map, .r, .col, .val, .type, .y, .header must be length 1 or 2, not 0, 0, 0, 0, 0, 0, 0 (might be a genuine error though).

So far missing is the functionality of named by-arguments in joins, e.g., the following does not work

left_join(band_members, band_instruments2, by = c("name" = "artist"))
animate_left_join(band_members, band_instruments2, by = c("name" = "artist"))

Whereas the following works as expected

band_instruments3 <- band_instruments %>% mutate(band = c("Beatles", "Beatles", "Stones"))

left_join(band_members, band_instruments3, by = c("name", "band"))
animate_left_join(band_members, band_instruments3, by = c("name", "band"))

@DavZim
Copy link
Collaborator Author

DavZim commented Mar 26, 2019

What is the current status of this PR, can we merge the branches or are we missing some functionality?

@coatless
Copy link

Just want to ping this PR to see the state.

I'd like to potentially scavenge some parts to automatically create figures for data instead of manually constructing figures (c.f. draw-r ). Are there any plans to move on this package formation soon (tm)?

@gadenbuie
Copy link
Owner

gadenbuie commented Aug 1, 2019

Overall, off the top of my head there are four main areas that require further attention:

  1. When we wrote the code for the package version gganimate was still pre-release. There have been changes in the API since then that have not been incorporated into this package.

  2. There are quite a few rough edges that need to be ironed out to make sure that the package works as advertised immediately after devtools::install_github(). More specifically, we need to clean up the namespace, move ggplot2 out of Depends and into Imports, and fill out documentation.

  3. We need to straighten out fonts. I have some local code that uses the ggfittext package to handle font sizes, which is a really nice feature and removes a lot of the font size fiddling. Using newer packages like ragg might be a good idea, too. Personally I tend to use showtext + sysfonts for easy access to Google Fonts. Regardless the happy path for font usage needs to be worked out and consistent throughout the package or it causes headaches and cryptic error messages.

  4. Documentation and tests. Ideally a pkgdown website that includes articles for each of the join styles (and any other action groups). This would provide a nice balance for users who just want to see/use the animations and others who would want to use the package.

Overall, I don't have a ton of any time to dedicate to work on this (although I would love to). Until the above are worked out, I don't mind that the package code lives in the pkg branch. It's now advertised from the master README and anyone who wants to experiment is welcome to check out and try the package version. Ideally, we'd make it out of the "experimental" stage and into the "maturing" stage before we move to master.

@gadenbuie
Copy link
Owner

@coatless You're welcome to scavenge here for anything relevant to your projects!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants