03:00
Working in R and RStudio
We specialize in data processing and capture of large life science data for social sciences and humanities
Data flow and processing
Data capture
Project data management
Registry data handling
HPC analyses
03:00
I’m stuck or need help
All good, ready to move on
Saving source and blank slates | 1 hour |
Project-oriented workflow | 1 hour |
How to name files & practicing safe paths | 1 hour |
Lunch break | 30 minutes |
R package management | 1.5 hours |
R installed? Pretty recent?
Recommended R ≥ 4.3.0
RStudio installed?
I’m on 2023.06.1 Build 524
What Did They Forget
to Teach You?
Establish the concept of the project as the basic organizational unit of work.
Apply best practices in and leverage benefits of working in RStudio projects, including
Creating robust file paths that travel well in time and space.
Constructing human and machine readable file names that sort nicely.
Differentiating workflow elements, analysis inputs, and analysis outputs in project structure to create navigable programming interfaces.
Restarting R frequently, with a blank slate.
The ability to move the project without breaking code or needing adapting
The ability to rerun the entire process from scratch
Don’t fret over past mistakes.
Raise the bar for new work.
self-explaining >>>
wordy, needy explainers
>>>
file salad
+ an out of date README
PLOS Computational Biology
Wilson, Bryan, Cranston, Kitzes, Nederbragt, Teal (2017)
R packages
base R
14 base + 15 recommended packages
ships with all binary distributions of R
For example, have you used lattice recently? 🤷
it came with your R installation, can use out of the box
library(lattice)
By default, in the default library
.Library
All libraries for the current session
.libPaths()
All installed packages
installed.packages()
2014+ magrittr pipe %>%
2021+ (R \(\geq\) 4.1.0) native R pipe |>
2022 Isabella Velásquez Understanding the native R pipe |> https://ivelasq.rbind.io/blog/understanding-the-r-pipe/
dplyr::select()
tells R explicitly to use the function select
from the package dplyr
can help to avoid name conflicts (e.g., MASS::select()
)
does not require library(dplyr)
install.packages("usethis")
library(usethis)
# saves project on desktop by default for most users
use_course("rstats-wtf/wtf-explore-libraries")
# use_course("rstats-wtf/wtf-explore-libraries", destdir = "my/new/location")
# can alternatively download from
# https://github.com/rstats-wtf/wtf-explore-libraries
Read the README.md
to get started.
01_explore-libraries_spartan.R
(directions to explore without suggested code)
01_explore-libraries_comfy.R
(directions to explore with suggested code)
01_explore-libraries_solution.R
(directions to explore with code solutions)
15:00