Unfortunately, we will not be able to get our course evaluations until the end of the semester. Students formally enrolled (both for credit or audit) should get an email with a link to the evaluation at that time, and I would really appreciate it if you can take a few minutes to answer the questions.
This course is continuously under active development, so I would really value everybody’s feedback on how we can improve it and make it as useful as possible.
Please share your candid thoughts and suggestions in the evaluation. Remember that all comments are completely anonymous and I only get to see it after S/U decisions have been submitted.
If anyone has feedback or suggestions they would like to share right
away, we would be happy to hear your thoughts! You can either private
message, email, or post in the feedback
channel on
Slack.
Resist the temptation to manually edit or reformat your original file because if your documentation of the changes is imperfect, you may lose important information. Clean up the data in R. Your R code, along with appropriate documentation will be a record of the changes. The code can be modified and rerun, using the raw data file as input, if needed.
Make sure that your code does not rely on objects or functions defined outside of your script. If that is the case, it can’t readily be run by yourself or someone else in the future.
Make sure to frequently re-start R as you’re working, as elaborated on by Jenny Bryan here.
Also, if you haven’t already, follow the instructions from r4ds on how ensure that RStudio does not restore your workspace between sessions, so you start with a clean environment every time. Make sure this option is selected under your RStudio preferences:
Slides from Deep thoughts by Jenny Bryan:
Organizing your work into RStudio projects avoids issues with absolute file paths and makes it easier to keep track of the code used to generate plots and reports, share your code with others, and work on multiple different projects in parallel. Not convinced yet? Check out What they forgot to teach you about R
Document the big-picture structure both within files (comments) and between files (README’s). In general, comments (and Git commit messages) should explain the why not the what (which should be self-evident from well-written code). Can a collaborator or you-in-six-months quickly figure out what’s going on in your code?
Developing a consistent style in your coding, makes it a lot easier to read. Here is some inspiration:
Very important advice from Vince Buffalo
Some ways to make code more human-readable include:
select(data, column_name)
instead of
data[,5]
An important principle for “writing data for computers” is to clean up and reshape your data into tidy format for analysis. That way, you can take advantage of the powerful set of tools available in the tidyverse and beyond instead of having to invent your own roundabout approaches, and this will both make your code more robust, concise, and readable. As a reminder, have another look at the Openscapes tidy data blog post
Here are a few other books you might want to check out:
And for getting help, check out the slide deck or recorded talk for Jenny Bryan’s talk “Object of type ‘closure’ is not subsettable” at the 2020 RStudio conference. You can also check out her Reprex webinar.
Can help write code and troubleshoot. But always important to check for accuracy. Can also help you learn R better (see e.g. here)
Dashboards:
Check out the Dashboard developed for the continually updated Coronavirus dataset we worked with earlier in the course. Note that you can grab all the code in the linked GitHub repo
Dashboards can also be made interactive with dynamic and user-controlled displays of data through use of Shiny, an R package that makes it easy to build interactive web apps straight from R.
For an example, check out this dynamic visualization of the gapminder dataset we worked with in our last class (make sure to check out the cool video with Hans Rosling)
Shiny let’s you create similar interactive displays. See for example a very simple example here, and materials for building a more advanced version here
For more examples, check out the RStudio Flexdashboard website. And check out Mastering shiny by Hadley Wickham
R has lots of functionality for making maps. See some examples of a beautiful application to illustrate the distribution patterns of birdpopulations through the Bird Genoscape Project
Some example code for making similar maps: https://github.com/eriqande/make-a-BGP-map?tab=readme-ov-file https://eriqande.github.io/rep-res-eeb-2017/plotting-spatial-data-with-ggplot.html https://eriqande.github.io/rep-res-eeb-2017/a-tidy-approach-to-spatial-data-simple-features.html
Here are some other useful tutorials: https://www.andrewheiss.com/blog/2023/07/28/gradient-map-fills-r-sf/index.html https://learning.nceas.ucsb.edu/2023-04-coreR/session_15.html
Here’s the cheatsheet for the very useful package sf https://github.com/rstudio/cheatsheets/blob/main/sf.pdf
If you need to use Python for part of your analysis, check out the reticulate package that facilitates interoperability between Python and R.
If you’re integrating multiple languages, or if you want to compile different types of outputs, also consider adopting Quarto in place of RMarkdown. Quarto is a multi-language, next-generation version of R Markdown from Posit and includes dozens of new features and capabilities while at the same being able to render most existing Rmd files without modification. Quarto combines the functionality of R Markdown, bookdown, distill, xaringian, etc into a single consistent system with “batteries included”, the developers say it reflects everything we’ve learned from R Markdown over the past 10 years. See an introductory tutorial for RStudio users here
Tips on how to start engaging on twitter from R for Excel Users by Julia Lowndes and Allison Horst
Finding the YOU in the R community by Thomas Mock
Go to the RStudio Tips twitter account (https://twitter.com/rstudiotips) and find one tip that looks interesting. Practice using it!
Here is an example of a very useful thread, listing RStudio shortcuts
From the Ocean Health Index Data Science Training:
If there are 3 things to communicate to others after this course, I think they would be:
1. Data science is a discipline that can improve your analyses
This helps your science:
2. Open data science tools exist
This helps your science:
3. Learn these tools with collaborators and community (redefined):
This helps your science:
Getting help, or really helping you help yourself, means moving beyond “it’s not working” and towards solution-oriented approaches. Part of this is the mindset where you expect that someone has encountered this problem before and that most likely the problem is your typo or misuse, and not that R is broken or hates you.
There is excellent advice for trouble-shooting R-code and how to get help in Lecture 2 from ESM 206: Statistics and Data Analysis in Environmental Science and Management by Allison Horst.