aba_read: Read an aba object from file

Description Usage Arguments Value Examples

View source: R/aba_readwrite.R

Description

This function allows you to read back into memory an aba object which was previously saved. This function is not relevant for loading results tables as you can just use read.csv or read_excel and the like. Note that this function essential just wraps readRDS for reading an Rda object.

Usage

1
aba_read(filename)

Arguments

filename

string. The filename where the aba object is saved.

Value

an aba object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# create temp files to save to
tmp_filename_rda <- tempfile(fileext = '.Rda')

# grab built-in data
data <- adnimerge %>% dplyr::filter(VISCODE == 'bl')

# fit a standard aba model
model <- data %>% aba_model() %>%
  set_groups(everyone()) %>%
  set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl) %>%
  set_predictors(
    PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl,
    c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl)
  ) %>%
  set_stats('glm') %>%
  fit()

# create a model summary
model_summary <- model %>% aba_summary()

# save model summary as an object which can be loaded back into memory
model_summary %>% aba_write(tmp_filename_rda, format = 'object')

# load summary back to file to show it works
model_summary2 <- aba_read(tmp_filename_rda)

# delete temp files
removed <- file.remove(tmp_filename_rda)

aba documentation built on Dec. 17, 2021, 1:06 a.m.