| Title: | R functions as an infrastructure for psychological research |
|---|---|
| Description: | psyinfr provides R functions that serve as the infrastructure for psychological research. |
| Authors: | Yoshihiko Kunisato |
| Maintainer: | Yoshihiko Kunisato <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.6.8 |
| Built: | 2026-10-08 17:36:42 UTC |
| Source: | https://github.com/ykunisato/psyinfr |
Add jpaQmd
add_jpaQmd()add_jpaQmd()
# add_jpaQmd()# add_jpaQmd()
Add paperQmd
add_paperQmd()add_paperQmd()
# add_paperQmd()# add_paperQmd()
Print a summary of the object returned by readJatos()
## S3 method for class 'jatos_data' print(x, ...)## S3 method for class 'jatos_data' print(x, ...)
x |
object of class |
... |
ignored |
Reads a JATOS results file (the text file exported from JATOS, in which each
line holds the jsPsych data of one component result) collected with
cbat4r::jatosify()-style tasks, and reshapes it into analysis-ready data
frames.
Three representations are produced:
trials: one row per jsPsych trial. All scalar trial fields (rt,
trial_type, trial_index, time_elapsed, ...) become columns; nested
fields (e.g. question_order) are collapsed with sep, and deeper
structures are kept as JSON text.
long: one row per response item (participant x task x trial x item).
response objects such as {"mood_1":1,"mood_2":0} are unnested into
item/value pairs, with a numeric copy in value_num.
wide: one row per participant, one column per response item, which is
the format usually wanted for statistical analysis.
Besides the line-delimited text export, a whole-file JSON array and the
JATOS "JSON with metadata" export are also accepted; in the latter case the
surrounding JATOS metadata (worker id, study result id, ...) is carried
along in columns prefixed with jatos_.
readJatos( file, format = c("all", "trials", "long", "wide"), id_col = "workerID", task_col = "taskName", response_col = "response", item_cols = character(), index_col = NULL, extra_cols = character(), prefix = c("auto", "always", "never"), sep = "|", drop_cols = character(), encoding = "UTF-8" )readJatos( file, format = c("all", "trials", "long", "wide"), id_col = "workerID", task_col = "taskName", response_col = "response", item_cols = character(), index_col = NULL, extra_cols = character(), prefix = c("auto", "always", "never"), sep = "|", drop_cols = character(), encoding = "UTF-8" )
file |
Path to a JATOS results file (e.g.
|
format |
One of |
id_col |
Name of the trial field identifying a participant. Default
|
task_col |
Name of the trial field identifying a task/component.
Default |
response_col |
Name of the trial field holding the response. Default
|
item_cols |
Character vector of further trial fields to treat as
response items, in addition to |
index_col |
Name of a trial field that numbers repeated items (e.g.
|
extra_cols |
Character vector of trial columns to carry into |
prefix |
How to name the columns of |
sep |
Separator used when collapsing a vector-valued field into one
string. Default |
drop_cols |
Trial columns to drop from |
encoding |
Encoding of |
A list of data frames (trials, long, wide) of class
jatos_data, or a single data frame if format is not "all".
# d <- readJatos("jatos_results_data_20260809054431.txt") # head(d$wide) # readJatos("jatos_results_data_20260809054431.txt", # format = "wide", extra_cols = "id") # # a task storing answers in custom fields, one set per aspect # readJatos("jatos_results_data_20261008071223.txt", # item_cols = c("aspect_text", "selected_adjectives"), # index_col = "aspect_number", # extra_cols = c("id", "completion_type"))# d <- readJatos("jatos_results_data_20260809054431.txt") # head(d$wide) # readJatos("jatos_results_data_20260809054431.txt", # format = "wide", extra_cols = "id") # # a task storing answers in custom fields, one set per aspect # readJatos("jatos_results_data_20261008071223.txt", # item_cols = c("aspect_text", "selected_adjectives"), # index_col = "aspect_number", # extra_cols = c("id", "completion_type"))
render function for Japanese e-labnotebook in PDF
render_elnjp_pdf(Rmd_file)render_elnjp_pdf(Rmd_file)
Rmd_file |
file name of R Markdown file |
Runs quarto render in the manuscript project, which produces the website
(_manuscript/index.html) and the PDF (_manuscript/paper.pdf).
The Render button of RStudio runs quarto preview, and a preview renders
only the first format of the project (the website), leaving the PDF to be
built when its download link is clicked. Use this function when the PDF
should be built every time.
When the render succeeds, _manuscript/index.html is opened in the browser.
render_manuscript(project_dir = ".", preview = FALSE, open = TRUE)render_manuscript(project_dir = ".", preview = FALSE, open = TRUE)
project_dir |
Directory of the manuscript project (the folder holding
|
preview |
If |
open |
If |
The exit status of the quarto command, invisibly.
# render_manuscript() # render_manuscript("manuscript")# render_manuscript() # render_manuscript("manuscript")
start research with new Japanese e-labnotebook
researchIn(rc = TRUE)researchIn(rc = TRUE)
rc |
If you are using Research Compendium of senshuRmd, you can create a e-labnotebook file in the "labnote" directory from the current directory. In that case, please set rc to TURE. |
# researchIn()# researchIn()
upload Japanese e-labnotebook to GitHub
researchOut(rc = TRUE)researchOut(rc = TRUE)
rc |
If you are using Research Compendium of senshuRmd, you can create a e-labnotebook file in the "labnote" directory from the current directory. In that case, please set rc to TURE. |
# researchOut()# researchOut()
run high load computing and psuh to GitHub
runHighLoad(r_file)runHighLoad(r_file)
r_file |
set r file to run |
# runHighLoad(r_file)# runHighLoad(r_file)
run r files using parallel
runParallelR(r_files)runParallelR(r_files)
r_files |
set vector of r files |
R Markdown output formats Template for thesis at Department of Psychology, Senshu University
senshu_thesis(Rmd_file, Bib_file)senshu_thesis(Rmd_file, Bib_file)
Rmd_file |
file name of R Markdown file |
Bib_file |
file name of Bib file |
Creates a Quarto manuscript project (project: type: manuscript) whose
article is paper.qmd taken from the senshuQmd template
(https://github.com/ykunisato/senshuQmd), together with two notebooks,
notebooks/Analysis_01.qmd and notebooks/Data_collection.qmd.
The layout created is:
<project>/
_quarto.yml
paper.qmd article (senshuQmd template)
bibliography.bib
figures/
_extensions/senshu/ senshu-pdf format
notebooks/
Analysis_01.qmd
Data_collection.qmd
data/
jatos_results_data_demo.txt
Data_collection.qmd holds an example of building an online survey with
cbat4r (set_ic(), set_qnr(), set_cc(), jatosify()) in an R
chunk, and Analysis_01.qmd an analysis skeleton that reads the demo data
in data/ with readJatos(), so that the project renders as it is.
set_manuscript( project_name = "manuscript", output_dir = ".", add_root_dir = TRUE, overwrite = FALSE, open = rstudioapi::isAvailable(), branch = "main" )set_manuscript( project_name = "manuscript", output_dir = ".", add_root_dir = TRUE, overwrite = FALSE, open = rstudioapi::isAvailable(), branch = "main" )
project_name |
Name of the manuscript project. Default |
output_dir |
Where the project is created. Default |
add_root_dir |
If |
overwrite |
If |
open |
If |
branch |
Branch of the senshuQmd repository to download. Default
|
The path of the created project, invisibly.
# set_manuscript() # set_manuscript("paper2026", output_dir = "paper")# set_manuscript() # set_manuscript("paper2026", output_dir = "paper")
Research Compendium of Department of Psychology, Senshu University
set_rc()set_rc()
# set_rc()# set_rc()
run high load computing and psuh to GitHub
setGitSlack( git_name, git_email, slack_token = "FALSE", slack_channel = "#general" )setGitSlack( git_name, git_email, slack_token = "FALSE", slack_channel = "#general" )
git_name |
set user name of GitHub |
git_email |
set e-mail of GitHub |
slack_token |
set slack API token |
slack_channel |
set channel name of slack |
# setGitSlack(user_name_github, email_github, slack_token, slack_channel, slack_username)# setGitSlack(user_name_github, email_github, slack_token, slack_channel, slack_username)
upload Japanese e-labnotebook to OSF
up2osf(eln_osf = TRUE, rc_osf = TRUE)up2osf(eln_osf = TRUE, rc_osf = TRUE)
eln_osf |
URL of pdf directory in OSF |
rc_osf |
If you are using Research Compendium of senshuRmd, you can create a e-labnotebook file in the "labnote" directory from the current directory. In that case, please set rc to TURE. |