ch.moralsDataClean: A function to cleans the choice data for analysis

ch.moralsDataCleanR Documentation

A function to cleans the choice data for analysis

Description

This function cleans the choice data for analysis by removing bad subjects (based on sn column), dropping columns, making sure the trials starts at 1, and computing average p(HVO) and RT for each subject.

Usage

ch.moralsDataClean(
  data,
  snCol,
  RTcol,
  trialCol,
  respChoiceCol,
  respChoiceVal = c("Item1", "Item2"),
  dropVarFilename = NULL,
  dropSNFilename = NULL,
  RTlogTransform = FALSE,
  outfile = NULL
)

Arguments

data

A dataframe containing the choice data.

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.

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).

dropVarFilename

A filename of a file that contains a vector of column names to be removed from "data" DEFAULT = NULL (remove nothing)

dropSNFilename

A filename of a file that contains a vector of subject names to be removed from "data" DEFAULT = NULL (remove nothing)

RTlogTransform

A boolean to specify whether to transform the RT variable to log(RT). DEFAULT = FALSE

outputFile

the filename that you want the output written to. DEFAULT = NULL (no file written)

Value

a dataframe of cleaned data.

Examples

ch.moralsDataClean (data=moralsData, "sn", "RT", "trials", "keyDef", dropVarFilename ="dropVars.txt", dropSNFilename = "badSNs.txt")

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