Make a script with all analyses
make_script(
study,
path = NULL,
data_path = "data",
data_format = "tsv",
show_codebook = TRUE,
use_rmarkdown = TRUE,
header_lvl = 2,
header = TRUE
)
A study list object with class scivrs_study
Path to write script to (outputs text if NULL)
Where to load data from external files (you may need to creates data files with `make_data or edit the script for your data paths); loads from the script if set to NULL
The data format to save with (defaults to tsv)
Include codebook for each dataset in comments
Creates an Rmarkdown file if TRUE, a .R file if FALSE
The starting header level for the section (defaults to 2)
Whether the rmarkdown version should have a header
Text of the script if path is NULL
s <- study() %>%
add_data("my_cars", mtcars) %>%
add_analysis("A1", cor.test(my_cars$mpg, my_cars$wt)) %>%
study_analyse()
#> mpg set to dataType float
#> cyl set to dataType int
#> disp set to dataType float
#> hp set to dataType int
#> drat set to dataType float
#> wt set to dataType float
#> qsec set to dataType float
#> vs set to dataType int
#> am set to dataType int
#> gear set to dataType int
#> carb set to dataType int
#> The study has no hypotheses.
# get Rmd text output
make_script(s) %>% cat()
#> ---
#> title: "Demo Study"
#> author: ""
#> date: "05/05/2024"
#> output:
#> html_document:
#> toc: true
#> toc_float: true
#> ---
#>
#>
#>
#> ## Data
#>
#> ### my_cars
#>
#>
#> * mpg (float)
#> * cyl (int)
#> * disp (float)
#> * hp (int)
#> * drat (float)
#> * wt (float)
#> * qsec (float)
#> * vs (int)
#> * am (int)
#> * gear (int)
#> * carb (int)
#>
#>
#> ```{r}
#> my_cars <- read.csv('data/my_cars_data.tsv', sep='\t')
#> ```
#>
#>
#>
#> ## Analysis 1: A1 {#analysis_1}
#>
#> ```{r}
#> cor.test(my_cars$mpg, my_cars$wt)
#> ```
#>
#> ### Stored Results
#>
#> * statistic:
#> * t: `-9.55904414697211`
#> * parameter:
#> * df: `30`
#> * p.value: `1.29395870135052e-10`
#> * estimate:
#> * cor: `-0.867659376517228`
#> * null.value:
#> * correlation: `0`
#> * alternative: `two.sided`
#> * method: `Pearson's product-moment correlation`
#> * data.name: `my_cars$mpg and my_cars$wt`
#> * conf.int:
#> 1. `-0.933826413284994`
#> 2. `-0.744087196460113`
#>
# get R text output
make_script(s, use_rmarkdown = FALSE) %>% cat()
#> # Code for Demo Study
#> # Authors:
#> # Created 05/05/2024
#>
#>
#>
#> ## Data
#>
#> ### my_cars
#>
#>
#> # * mpg (float)
#> # * cyl (int)
#> # * disp (float)
#> # * hp (int)
#> # * drat (float)
#> # * wt (float)
#> # * qsec (float)
#> # * vs (int)
#> # * am (int)
#> # * gear (int)
#> # * carb (int)
#>
#> my_cars <- read.csv('data/my_cars_data.tsv', sep='\t')
#>
#>
#>
#> ## Analysis 1: A1
#>
#> cor.test(my_cars$mpg, my_cars$wt)
#>
#> ### Stored Results
#>
#> # * statistic:
#> # * t: -9.55904414697211
#> # * parameter:
#> # * df: 30
#> # * p.value: 1.29395870135052e-10
#> # * estimate:
#> # * cor: -0.867659376517228
#> # * null.value:
#> # * correlation: 0
#> # * alternative: two.sided
#> # * method: Pearson's product-moment correlation
#> # * data.name: my_cars$mpg and my_cars$wt
#> # * conf.int:
#> # 1. -0.933826413284994
#> # 2. -0.744087196460113
#>