# DEBUG
# targets::tar_load_globals()
# DF_clean = read_rds(here::here("_targets/objects/DF_clean"))
# DF_raw = read_rds(here::here("_targets/objects/DF_raw"))
# params = list(
#   pid_report = 0,
#   last_task = "Goodbye"
# )

knitr::opts_chunk$set(echo = TRUE)
targets::tar_load(DF_clean)
targets::tar_load(DF_raw)
DF = DF_clean
# Plot created in report_PROGRESS.Rmd
# plot_form_progress = show_progress_pid(pid = params$pid_report, files_vector = DF_clean$filename, last_task = params$last_task, goal = 500)$PLOT_progress
# 
# ggsave(here::here("outputs/plots/plot_form_progress.png"), plot_form_progress, width = 15, height = 9, bg = "white")

Summary {.tabset}

number_participants = DF_raw %>% distinct(id) %>% nrow()

number_tasks = DF_raw %>% distinct(experiment) %>% nrow()

text_participants = 
  DF_raw %>% 
  count(id, experiment) %>% 
  count(id, name = "tasks") %>% 
  count(tasks, name = "people") %>% 
  arrange(desc(tasks))

Tasks and participants

We had a total of r number_participants participants completing up to r number_tasks different tasks.

DT::datatable(text_participants,
              width = "50%",
              rownames = FALSE,
              options = list(dom = 't',
                             pageLength = 20))

By participant

all_tasks = DF_raw %>% distinct(experiment) %>% pull(experiment)

summary_table = 
  DF_raw %>% 
    select(id, experiment, rt) %>% 
    mutate(rt = as.numeric(rt)) %>% 
    group_by(id, experiment) %>% 
    summarise(TIME = round(sum(rt, na.rm = TRUE)/60000, 2), # TIME = round(max(time_elapsed)/60000, 2), # time_elapsed is cumulative!
              N = dplyr::n(), 
              .groups = "keep") %>% 
    group_by(id) %>% 
    summarise(TIME = sum(TIME), 
              N = dplyr::n(), 
              tasks = paste(experiment, collapse = ", "),
              .groups = "keep") %>% 
      mutate(missing = paste(all_tasks[!all_tasks %in% (strsplit(tasks, split = ", ") %>% unlist())], collapse = ", "))

DT::datatable(summary_table, filter = 'top', options = list(dom = 'ltip', pageLength = 10))

By task

# Using time_elapsed overestimates time by a lot. NOT sure why
# summary_table2 =
#   DF_raw %>% 
#     group_by(id, experiment) %>% 
#     summarise(
#       n_participants = n_distinct(id),
#       time = max(time_elapsed) / 60000,
#       .groups = "drop"
#     ) %>% #View
#   
#     group_by(experiment) %>% 
#     summarise(
#       n_participants = dplyr::n(),
#       mean_time = round(mean(time), 1),
#       time_elapsed_min = round(min(time), 1),
#       time_elapsed_max = round(max(time), 1),
#       .groups = "keep"
#     )


 summary_table2 =
   DF_raw %>% 
    select(id, experiment, rt) %>% 
    mutate(rt = as.numeric(rt)) %>% 
    group_by(id, experiment) %>% 
    summarise(TIME = round(sum(rt, na.rm = TRUE)/60000, 2), # TIME = round(max(time_elapsed)/60000, 2), # time_elapsed is cumulative!
              N = dplyr::n(), 
              .groups = "drop") %>% 
    group_by(experiment) %>% 
summarise(
      n_participants = dplyr::n(),
      mean_time = round(mean(TIME), 1),
      time_elapsed_min = round(min(TIME), 1),
      time_elapsed_max = round(max(TIME), 1),
      .groups = "keep"
    )


DT::datatable(summary_table2, filter = 'top', options = list(dom = 'ltip', pageLength = 10))

By task and participant

# Using time_elapsed overestimates time by a lot. NOT sure why
# summary_table3 =
#   DF_raw %>% 
#     group_by(id, experiment) %>% 
#     summarise(
#       # n_participants = n_distinct(id),
#       time = round(max(time_elapsed) / 60000, 2),
#       .groups = "drop"
#     ) 

summary_table3 = 
  DF_raw %>% 
  select(id, experiment, rt) %>% 
  mutate(rt = as.numeric(rt)) %>% 
  group_by(id, experiment) %>% 
  summarise(TIME = round(sum(rt, na.rm = TRUE)/60000, 2), # TIME = round(max(time_elapsed)/60000, 2), # time_elapsed is cumulative!
            items = dplyr::n(), 
            .groups = "drop")



DT::datatable(summary_table3, filter = 'top', options = list(dom = 'ltip', pageLength = 10))

Order of tasks

summary_position = DF_raw %>% 
  distinct(id, experiment, datetime) %>% 
  group_by(id) %>% 
  arrange(id, (datetime)) %>% 
  mutate(Order = row_number()) %>% 
  select(-datetime) %>% 
  group_by(experiment) %>% 
  summarise(MEAN_Position = round(mean(Order), 1),
            SD_Position = round(sd(Order), 1),
            MIN_Position = min(Order), 
            MAX_Position = max(Order), 
            .groups = "drop") %>% 
  arrange(MEAN_Position, experiment)

DT::datatable(summary_position, filter = 'top', options = list(dom = 'ltip', pageLength = 10))

Details of tasks {.tabset}

Items per task

# Alternative trialid for each scale
trialid_table = DF %>% 
  filter(trial_type != "fullscreen") %>% 
  select(experiment, trial_type, trialid, response) %>% 
  group_by(experiment) %>% 
  distinct(trialid) %>% 
  count(experiment, name = "number_items")


DT::datatable(trialid_table, 
              filter = 'top', 
              options = list(dom = 'ltip', 
                             pageLength = 15))

Trialid's and questions

# trialid and question_text for each experiment
trialid_detail_table = DF %>% 
  select(experiment, trialid, stimulus) %>% 
  group_by(experiment) %>% 
  distinct(trialid, stimulus) 


DT::datatable(trialid_detail_table, 
              filter = 'top', 
              options = list(dom = 'ltip', 
                             pageLength = 15))

Dimensions

# All tasks
tasks = list.files(here::here("R_tasks"), pattern = "\\.R", full.names = TRUE)

# Extract information for dimensions...
DF_dims = 1:length(tasks) %>%
  map_df(~
        {
          # cat(.x, "\n")
          create_codebook(tasks[.x])
        }
  )

DT::datatable(DF_dims, 
              filter = 'top', 
              options = list(dom = 'ltip', 
                             pageLength = 15))

Responses

# Alternatives responses for each scale
responses_table = DF |> 
  # distinct(trial_type)
  select(experiment, trial_type, trialid, response) |> 
  # filter(trial_type %in% c("survey-multi-choice-vertical", "survey-multi-choice-horizontal", "likert", "html-slider-response")) |> 
  group_by(experiment) |> 
  distinct(trialid, response) 

DT::datatable(responses_table, 
              filter = 'top', 
              options = list(dom = 'ltip', 
                             pageLength = 15))
#   DF_responses =
#     DF %>%
#     count(trialid, experiment, responses) %>%
#     group_by(experiment, trialid) %>%
#     summarise(N = dplyr::n(),
#               Responses = paste(responses, collapse = ", "),
#               .groups = "drop") %>%
#     group_by(experiment, Responses) %>%
#     summarise(N = dplyr::n(),
#               trialid = paste(trialid, collapse = ", "),
#               .groups = "drop") %>% 
#   select(experiment, trialid, Responses, N)
# 
# 
# DT::datatable(DF_responses, 
#               filter = 'top', 
#               options = list(dom = 'ltip', 
#                              pageLength = 15))


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