Creating a project-oriented workflow in R
Leibniz-Zentrum Allgemeine Sprachwissenschaft
Tue Oct 8, 2024
here
package4.4.0
, “Puppy Cup”R.version
2023.12.1.402
, “Ocean Storm”.Rproj
file in a project folderSoSe2024
or Mastersarbeit
File > New Project > New Directory > New Project > [Directory name] > Create Project
New R-Project
Create a new R-Project for this workshop
File > New Project > New Directory > New Project > [Directory name] > Create Project
.Rproj
file and double-clickProject (None)
drop-down (top right)File > New File > Markdown File
(not R Markdown!)
#
for headings, *italics*
, **bold**
)README.md
in youR-Project directoryTools > Global Options
Global settings
Change your Global Options so that
data
: containing your dataset(s)scripts
(or analyses
, etc.): containing any analysis scriptsmanuscript
: containing any write-ups of your resultsmaterials
: containing relevant experiment materials (e.g., stimuli)data
and scripts
)data/
raw
sub-folderprocessed
or tidy
)cwiek_2021-online_cleaned.csv
In an online experiment with listeners of 25 different languages (from nine language families), participants listened to the 90 vocalizations (three for each of the 30 meanings), and for each, guessed its intended meaning from six written alternatives
– Ćwiek et al. (2021)
scripts/
New script
Create a new script:
File > New File >
Choose your preferred script typescripts/
folder: File > Save as...
read.csv()
, readr::read_csv()
, …R-Project template
rproject-template.Rproj
scripts/
folder. Is it clear which scripts should be run first?02-visualisation.R
first. Do you encounter any problems?here
-packagehere
package (Müller, 2020) enables file referencing
setwd()
setwd()
If the first line of your R script is
setwd("C:\Users\jenny\path\that\only\I\have")
I will come into your office and SET YOUR COMPUTER ON FIRE🔥.
Error in setwd("/Users/danielapalleschi/Documents/R/rproject-template") :
cannot change working directory
here()
here
In your R Project, load the cwiek_2021-online_cleaned.csv
data using here
here::here()
here
functionhere
function without loading the packagedf_
df
stands for dataframefit_
for models, fig_
for figures, sum_
for summaries, tbl_
for tables, etc.Reproduce your analysis
names()
, summary()
, dplyr::glimpse()
, whatever you typically do)here
package ✅R-Projects and {here}