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

add data(name, package) to code export #150

Closed
GregorDeCillia opened this issue Apr 15, 2021 · 4 comments
Closed

add data(name, package) to code export #150

GregorDeCillia opened this issue Apr 15, 2021 · 4 comments

Comments

@GregorDeCillia
Copy link

Hello. Let me first say thank you for this fantastic package. I'll use this package soon for a datviz course and would like to suggest a small, but significant improvement.

When datasets are loaded from packages, the R code export does not contain any lines to load the dataset in the environment. It would be very useful for beginners if you could add a line like data(name, package) or package::name here, so the generated code can be run without any setup operations. Example

data("tips", package = "reshape2")
ggplot(tips) + aes(total_bill, tip, colour = smoker, size = size) + geom_point() 

or

ggplot(reshape2::tips) + aes(total_bill, tip, colour = smoker, size = size) + geom_point() 
@pvictor
Copy link
Member

pvictor commented Apr 16, 2021

Hello,
Thank you 😄

Good idea, I've implemented option 2 (easier). You have to re-install esquisse and datamods from GitHub :

remotes::install_github("dreamRs/datamods")
remotes::install_github("dreamRs/esquisse")

I'll plan a release on CRAN next week.

Best,

Victor

@GregorDeCillia
Copy link
Author

GregorDeCillia commented Apr 16, 2021

Thank you very much! After the update of datamods and esquisse, the data is imported with the :: syntax. However, I am now running into issues with the dplyr filters. In the plot below, all levels of reshape2::tips$day are displayed even tough the code export uses

`reshape2::tips` %>% filter(day %in% c("Sun", "Sat"))

I assume this has something to do with the implementation of this feature since datasets from the global environment are filtered correctly. Another thing I noticed is that there are backticks (`) around the dataset name.

esquisser

@pvictor
Copy link
Member

pvictor commented Apr 19, 2021

Ah yes thanks, should be solved if you re-install both packages (esquisse and datamods).

This was caused by the fact that even if the data is not specified in the displayed code, the executed code contains a call to ggplot(reshape2::tips) and this object can't be overwritten by the new data filtered.

Victor

@GregorDeCillia
Copy link
Author

Works like a charm now. Thanks a lot for your efforts!

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

No branches or pull requests

2 participants