# knitr::opts_chunk$set(echo = TRUE)

# DEBUG
  # Makes sure all libraries and functions are available to work interactivelly
  # targets::tar_load_globals() # Loads all libraries

# Loads DF_analysis
targets::tar_load(DF_analysis)

# In this document you will find a template to run analysis, plots, and tables
# You will need to adapt to the contents of your DF_analysis
# names(DF_analysis$DF_analysis) # Show variable names in DF_analysis

Data preparation

Descripción del proceso de preparación de datos.

DF =
 DF_analysis$DF_analysis %>% 

  # Update with your variable names
  select(id, ends_with("_DIRd"), ends_with("_DIRt"))

  # Continue your data preparation, if needed
  #   filter() %>% 
  #   drop_na()

Descriptive tables

Tabla 1. Descripción de la tabla 1. Tabla 2. ...

# You can add a variable to the `by` argument and uncomment
# names(DF) shows the variables you hava available


table1 = DF |>
  dplyr::select(where(is.numeric), -id, -Goodbye_DIRt) |> 
  gtsummary::tbl_summary(
    # by = AIM_DIRt,
    type = list(everything() ~ 'continuous')
    )

table1

Plots

Figura 1. Descripción de la Figura 1. Figura 2. ...

# Remember to change the variables in your plot

plot1 =
  DF %>%
  ggplot(aes(EAR_DIRt, IRI_TomaPerspectiva_DIRd)) +
  geom_jitter() +
  geom_smooth(method = "lm")

plot1

Analysis

# Remember to change the variables used in your model and inline_text 

model1 = lm(EAR_DIRt ~ IRI_DIRt, DF)

table_model = gtsummary::tbl_regression(model1, intercept = TRUE) %>% 
  # add_global_p() %>%
  bold_labels() %>% 
  italicize_levels() %>% 
  add_glance_table(include = c("nobs", "df.residual", "r.squared", "adj.r.squared"))

table_model

# report::report(model1)

paste0("IRI was not a significant predictor of EAR", 
       ", beta = ", 
       gtsummary::inline_text(table_model, variable = IRI_DIRt))


gorkang/jsPsychHelpeR documentation built on Oct. 15, 2024, 8 a.m.