Skip to content

Basics of R

etiaum edited this page Jan 10, 2025 · 1 revision

By Étienne Aumont

Managing CSVs

You can load a CSV file for your R script using the read.csv() function. This creates a dataframe. You must instantiate a variable to refer to that dataframe using the variable name.

   data_MCSA<- read.csv('/Users/path/toyour/sheet/mcsa_sheet_20250106.csv')

Similarly, you can generate CSV files from your dataframe using the write.csv() function

   write.csv(data_MCSA, '/Users/path/toyour/newsheet/mcsa_sheet_20250110.csv')

You can also easily merge sheet with the merge() as long as one variable is in common. The result will be one dataframe with variables names ending in .x when originating from the first dataframe, and .y when originating from the second dataframe

   data_ravlt <- read.csv('/Users/path/toyour/sheet/RAVLT_2025-01-08.csv')
   data_1 <- merge(data_MCSA, data_ravlt, by = "PID", all.x = TRUE)

Clone this wiki locally