cRayton is an R package that provides a collection of functions designed to simplify data wrangling and formatting. The package includes utilities for joining data frames based on timepoints, reading multiple file formats, merging and cleaning data, and more. Use cases might be specific to UCSF's Memory and Aging Center.
To install cRayton, use:
# install locally from source
install.packages("cRayton")
Joins a primary dataframe containing patient IDs (PIDN) and timepoints (dates) to a list of dataframes based on the closest date within a specified maximum day difference (max_day_difference
). After joining, duplicates are removed, and the resulting dataframes are consolidated into a single tibble.
Reads multiple files (CSV and Excel), cleans the column names, and stores the dataframes in an array.
A file-type agnostic function for importing various file formats, including CSV, TXT, RDS, and XLSX.
An interactive file importing function that utilizes read_data
and allows interactive object naming.
Joins two data frames while coalescing matching columns. In the case of NA
values, the function prioritizes the left-hand side data frame.
Removes duplicate dataframes from a list and merges dataframes with the same name together.
library(cRayton)
# Example: Using join_list_of_dfs_to_timepoints
result <- join_list_of_dfs_to_timepoints(primary_df, list_of_dfs, max_day_difference = 7)
# Example: Reading all files in a directory
files_data <- read_all_files("path/to/directory")
Contributions are welcome! Feel free to submit issues or pull requests.
This project is licensed under the MIT License.