class: center, middle, inverse, title-slide # Lec14: Sharing your Work ## Stat41: Data Viz ### Prof Amanda Luby ### Swarthmore College --- # Today: (1) Sharing a final product (2) Sharing code (3) Making it public --- But first, we have to have **the talk**. -- About the **yellow ggplot2 theme** (goes for other colored backgrounds, too). -- .pull-left[ Example from "She giggles, he gallops": <img src="images/yellow-background-good.png" width="2088" style="display: block; margin: auto;" /> ] -- .pull-right[ Example with `penguins`: <img src="images/yellow-background-bad.png" width="1283" style="display: block; margin: auto;" /> ] -- The **bottom line**: use with caution, take extra step of making entire document nice --- # Reports: HTML vs PDF Examples in Google Drive -- .pull-left[ ### HTML: - Better for code sharing - Reads better on computer - Larger files - Harder to share via email/moodle ] -- .pull-right[ ### PDF: - Ubiquitious for sharing files - Reads better on paper - Shows up the same on everyone's computer ] -- The **Bottom Line:** if your final report is "academic paper" style, use PDF. If it's "blog post" style/you want to talk about code, use HTML. Either way, I expect your final report to be extremely polished. --- # Presentations Examples in Google Drive -- .pull-left[ ### Within rmarkdown - ioSlides (HTML) - Xaringan (HTML) - Beamer (PDF) ] -- .pull-right[ ### Export graphs, separate presentation file - Google slides - Powerpoint ] -- The **Bottom Line**: I don't care how you make your presentations, as long as they are clean, readable, and well-thought-out. --- # Saving Graphics in R I like `ggsave()`: ```r ggsave("super-pretty-ggplot.pdf", p1, device = cairo_pdf) # Use cairo_pdf for custom fonts ``` If you have a non-ggplot, you can also use `pdf()`: ```r pdf('super-pretty-non-ggplot.pdf') dev.off() # Not written to file until you run this line ``` OR can use `Export --> PDF` in RStudio When adding graphs that you saved to your presentation, avoid stretching them after including them in your presentation. If you want to change their dimensions, do this by adjusting the parameters in the functions above and re-generating the graphs. Keep in mind that your graphics will be much bigger when presenting, so make sure your graphic is readable, clean and clear at different zoom levels. Additionally make sure font sizes are not too small. --- # Sharing Code - Can be within rmarkdown output - Or a separate .rmd file - For PDF documents, I recommend: ```{} # Appendix: All code for this report {r ref.label=knitr::all_labels(), echo=TRUE, eval=FALSE} ``` --- # Style guide Whenever you include code in a document, you want to make sure it's **readable**. For this class, I like the [`tidyverse` style guide](https://style.tidyverse.org) > The most important thing about a style guide is that it provides consistency, making code easier to write because you need to make fewer decisions. --- # The most important things: -- 1. Code in rmarkdown chunks doesn't get cutoff from the page (use "enter" in your code) -- 2. Anytime you use a pipe `%>%` or a ggplot `+`, you should start a new line -- 3. Just like writing English, put spaces after commas and around `=` or `<-` --- # Sharing code (with me or in the future) MAKE SURE YOU INCLUDE YOUR DATA -- Use relative paths + rmarkdown is "smart" about where your .rmd file is stored + `read_csv("~/Users/aluby/Desktop/stat41/final-project/data/dataset.csv")` is the same as + `read_csv("data/dataset.csv")` if your .rmd is in the `final-project` folder + Relative paths are better for sharing! -- For sharing code in general, **github** is the gold standard. + I highly recommend [happy git with R](https://happygitwithr.com/workshops.html) + If you take the plunge, I'm happy to help you troubleshoot (after the J-term!) --- <img src="https://imgs.xkcd.com/comics/git.png" height="90%" style="display: block; margin: auto;" /> --- ### If you're not ready to take the github plunge, - Use google drive! (or dropbox, etc.) + Google doc as a table of contents with links to project sub-folders + Each project includes code, data, and output - Anywhere you can upload files and link to, you can share code --- # Tidy Tuesday [Tidy Tuesday](https://github.com/rfordatascience/tidytuesday) is a great, low-stakes way to keep your visualization skills sharp and share your work publicly -- > Join the R4DS Online Learning Community in the weekly #TidyTuesday event! Every week we post a raw dataset, a chart or article related to that dataset, and ask you to explore the data. While the dataset will be “tamed”, it will not always be tidy! As such you might need to apply various R for Data Science techniques to wrangle the data into a true tidy format. The goal of TidyTuesday is to apply your R skills, get feedback, explore other’s work, and connect with the greater #RStats community! As such we encourage everyone of all skills to participate! -- Sharing is done via twitter and the `#TidyTuesday` hashtag --- # Swat Data Viz Introducing.... A new **Swarthmore Data Visualization Group**! -- - Slack group -- - [Blog](https://aluby.domains.swarthmore.edu/sdv/) -- soon-to-be swatdataviz.com -- - Zoom co-working time (???) -- We'll get started the first Tuesday of the spring semester (Feb 16) -- I'd love to fill out the blog site during the break. To be featured on the "contributors" page, send me 3 .rmd files in "blog post" style; any contact info you want me to include, and a 1-2 sentence bio (eg "Amanda is currently a statistics professor at Swarthmore College. Her favorite color palette right now is the `plasma` variant of `viridis`") --- class: inverse, center, middle # The Plan for Thursday --- ### Other course wrap-up announcements: - Sign up for a meeting with me if you haven't already (in google drive) -- - **All** labs and projects (besides final papers) due on Thursday at midnight - this includes resubmissions -- - If you are pre-recording your presentation, I need to have it by 10am if you're in the morning session and 12pm if you're in the afternoon session. Please give me a heads up if this is you. -- - Don't forget about the final project checklist -- - When you submit your final reports, PLEASE include a self-grade as a comment or separate file on moodle. You should self-evaluate both your presentation and your report. -- - At some point in the future, I'll create a "final grade" column in the moodle gradebook and include a breakdown of your labs/projects/participation