Skip to content

Instantly share code, notes, and snippets.

@WillForan
Last active October 20, 2023 18:38
Show Gist options
  • Save WillForan/e97865204fad4ac43791c9ab7f6d6724 to your computer and use it in GitHub Desktop.
Save WillForan/e97865204fad4ac43791c9ab7f6d6724 to your computer and use it in GitHub Desktop.
using R and LNCDR for a visit age waterfall plot
# get needed libraries
install.packages(c('remotes','readxl', 'ggplot2'))
remotes::install_github('LabNeuroCogDevel/LNCDR')
library(LNCDR)
# read in data
# expects a row per visit with a column for id shared across visit and age at visit
# TODO: replace my_data.xlsx with actual excel document path/name
mydata <- readxl::read_xlsx("my_data.xlsx")
# rename columns to expected: "id" and "age"
# TODO: replace my id column and my age column with what's in excel sheet
data_for_waterfall <- mydata %>% select(id=`my id column`,age=`my age column`)
# plot
# TODO: see https://github.com/LabNeuroCogDevel/LNCDR#waterfall_plot for color and saving
waterfall_plot(data_for_waterfall)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment