summaryMSDSE: summaryMSDSE

View source: R/psychReportData.R

summaryMSDSER Documentation

summaryMSDSE

Description

Aggregate data returning the mean, standard deviation, and standard error

Usage

summaryMSDSE(data, factors, dvs, withinCorrection = NULL)

Arguments

data

A dataframe

factors

List of factors over which to aggregate

dvs

List of numeric data columns to aggregate

withinCorrection

List of dvs which to apply within-subjects correction to the calculation of the standard deviation and standard error. Within-subject correction calculated according to Morey (2008). NB Data should be normed first (see normData).

Value

dataframe

Examples

# Example 1:
library(dplyr)
dat <- createDF(nVP = 50, nTrl = 50, design = list("Comp" = c("comp", "incomp")))
dat <- addDataDF(dat,
  RT = list(
    "Comp comp" = c(500, 80, 100),
    "Comp incomp" = c(550, 80, 140)
  ),
  Error = list(
    "Comp comp" = 5,
    "Comp incomp" = 10
  )
)
datAggVP <- dat %>%
  group_by(VP, Comp) %>%
  summarize(
    N  = n(),
    RT = mean(RT[Error == 0]),
    ER = (sum(Error) / N) * 100
  )
datAgg <- summaryMSDSE(datAggVP, "Comp", c("RT", "ER"))

# Example 2:
dat <- createDF(nVP = 50, nTrl = 50, design = list("Comp" = c("comp", "incomp")))
dat <- addDataDF(dat,
  RT = list(
    "Comp comp" = c(500, 80, 100),
    "Comp incomp" = c(550, 80, 140)
  ),
  Error = list(
    "Comp comp" = 5,
    "Comp incomp" = 10
  )
)
datAggVP <- dat %>%
  group_by(VP, Comp) %>%
  summarize(
    N = n(),
    RT = mean(RT[Error == 0]),
    ER = (sum(Error) / N) * 100
  )
datAggVP <- normData(datAggVP, "VP", c("RT", "ER"))
datAgg <- summaryMSDSE(
  datAggVP, "Comp", c("RT", "ER", "RT_norm", "ER_norm"),
  c("RT_norm", "ER_norm")
)

psychReport documentation built on Sept. 9, 2022, 5:08 p.m.