ch.moralsDataPrep: A function to prepare the morals data for analysis

ch.moralsDataPrepR Documentation

A function to prepare the morals data for analysis

Description

This function prepares the morals data for analysis by creating overlapRound, correct, and a few other columns. It also makes sure the trials starts at 1, and computes average p(hit) and RT for each subject.

Usage

ch.moralsDataPrep(
  data,
  dat.over,
  snCol,
  RTcol,
  overlapCol,
  directionCol,
  trialCol,
  respChoiceCol,
  respChoiceVal = c("Item1", "Item2"),
  item1cols = c("Item1"),
  item2cols = c("Item2"),
  overlapItem1cols = c("IA1"),
  overlapItem2cols = c("IB1"),
  statsOutputFile = NULL,
  params,
  overlapDataIsComplete = FALSE
)

Arguments

data

morals dataframe.

dat.over

A dataframe with the overlap data processed from a typical values experiment.

snCol

a string that specifies the name of the column in "data" that contains the subject number.

RTcol

a string that specifies the name of the column in "data" that contains the RT for each trial.

overlapCol

a string that specifies the name of the column in "data" that contains the overlaps for the item in each trial.

directionCol

a string that specifies the name of the column in "data" that contains the direction of the overlap for each trial.

trialCol

a string that specifies the name of the column in "data" that contains the trial number.

respChoiceCol

a string that specifies the name of the column in "data" that contains the the participant's response to the prompt - yes take action or no take no action.

respChoiceVal

a vector of two values that specifies the choose Item1 option ("yes" take action in many morals experimants, thus saving Item1) value (index 1) and the choose Item1 option ("no" take no action in many morals experimants, thus saving Item2) value (index 2).

item1cols

a vector of strings that specifies the names of the columns in "data" that contains the the probes in Item 1.

item2cols

a vector of strings that specifies the names of the columns in "data" that contains the the probes in Item 2.

overlapItem1cols

a vector of strings that specifies the names of the columns in the overlaps file that contains the correspoinding probes in Item 1.

overlapItem2cols

a vector of strings that specifies the names of the columns in the overlaps file that contains the correspoinding probes in Item 2.

statsOutputFile

the filename that you want the statistics summary output written to. DEFAULT = NULL (construct filename from "params")

params

a list of parameters that are read in using "ch.readMoralsDBfile.r."

overlapDataIsComplete

A boolean that specifies whether the overlap data contains all the possible trial stimuli in the exact column order (TRUE) or whether the overlap file contains the trial stimuli in only one order and therefore has to be permuted to be merged with the choice data (FALSE). DEFAULT = FALSE.

Value

a dataframe of prepared data. It also writes the data to prepDataOutFile (specified in params) which will be used by other functions.

Examples

ch.moralsDataPrep (data=moralsData, "sn", "RT", "overlap", "direction", "trials", "respDef", respChoiceVal = c("Yes", "No"), params=parameters)

ccpluncw/ccpl_R_chMorals documentation built on Feb. 4, 2024, 3:30 p.m.