save_json: Save JSON files

View source: R/save_json.R

save_jsonR Documentation

Save JSON files

Description

This function does the same as save_lists, but in json format instead of csv format. It will write .js files that you can import directly into your experiment. Stimuli that present multiple levels on a single trial will be saved as an object with the stimulus name. For example, audio_1 = x and audio_2 = y will be converted into audio = audio_1 = x, audio_2 = y. If x and y are greater than length 1 for some reason, they will be converted to an an array within the audio object.

Usage

save_json(
  design,
  filename = gsub(" ", "_", design[["name"]]),
  objectname = "stimulist",
  extension = ".json",
  separate_items = FALSE,
  as_one_file = FALSE,
  remove_type = FALSE
)

Arguments

design

Experimental design

filename

Filename you want to use for each list (number will be appended)

objectname

Name you want to use for the js object in the file

extension

File extension, defaults to .js

separate_items

Should different item types be saved in separate files

as_one_file

Should all stimuli be saved as one file (NOT recommended)

remove_type

Should the type column be removed from the output file? If TRUE and there's only 1 type, the item column is renamed to the 1 value of the type column. If FALSE, type column is retained. If a string, will remove the type column and rename the item column to the given string.

Details

If you use a .js extension, it will save a javascript file with the list saved to the object name given with objectname. Using .json will prevent this.


tsostarics/stimulist documentation built on May 14, 2022, 6:49 p.m.