calc_cmean: Calculate conditional sample means and standard errors

Description Usage Arguments Value Examples

View source: R/calc_cmean.R

Description

calc_cmean() is a function that calculates sample means (plus standard errors and confidence intervals) by group.

Usage

1
calc_cmean(DT, y, x, se = F)

Arguments

DT

a data.table

y

a character vector of column names of data to calculate the group mean of

x

a character vector of columns in data to group by

se

logical, if TRUE output will calculate standard error and confidence intervals of mean alng with number of observations of conditional sample mean

Value

The data.frame/data.table of conditional sample means

Examples

1
2
3
4
5
6
library(data.table)
data <- data.table(x1 = sample(1:5, 1000, replace = TRUE),
                   x2 = sample(1:2, 1000, replace = TRUE))
data[, y := 2*x1 + 4*x2 + rnorm(mean = 0, sd = 2, n = 1000)]

calc_cmean(data, y = c("y"), x = c("x1", "x2"))

evanjflack/cfo.behavioral documentation built on Oct. 10, 2020, 11:52 p.m.