analysis_draft_3_final.R
.Instead, they should be saved as:
arrow
package to work with larger than memory data setsThe Tidyverse Style Guide is a great resource for style guidance.
Sectioning your code makes it easy for you and others to find the part of the analysis that you’re looking for at a glance.
cannot open file 'important-data.csv': No such file or directory
? They probably didn’t set the directory for you!Desktop/Medical_files/hair-transplant/important-data.csv
. Be kind, use a relative file path instead.Relative paths specify locations starting from the current location.
# Relative file path to a dedicated folder with raw data files
setwd("~/example-repo/RAW")
read.csv("important-data.csv")
# Call on another R source file back at the root of the directory
setwd(".")
source("analysis.R")
# Save the results of the analysis in it's own folder
setwd("/Cleaned_data")
write.csv(data_output, "data_output.csv")
# Bad
spec_data |>
mutate(scatter_normalized = scatter / 2.8)
# Better
spec_data |>
# Normalize by dividing by constant from calibration
mutate(scatter_normalized = scatter / 2.8)
# Best
# Load analysis that generates constant
source("spec_calibration.R")
spec_data |>
# Normalize by dividing by constant from calibration
mutate(scatter_normalized = scatter / calibration_value)
Data Practices for Open Science