phe_mean: Calculate Means using phe_mean

View source: R/Means.R

phe_meanR Documentation

Calculate Means using phe_mean

Description

Calculates means with confidence limits using Student's t-distribution method.

Usage

phe_mean(data, x, type = "full", confidence = 0.95)

Arguments

data

a data.frame containing the data to calculate means for, pre-grouped if multiple means required; unquoted string; no default

x

field name from data containing the values to calculate the means for; unquoted string; no default

type

defines the data and metadata columns to be included in output; can be "value", "lower", "upper", "standard" (for all data) or "full" (for all data and metadata); quoted string; default = "full"

confidence

the required level of confidence expressed as a number between 0.9 and 1 or a number between 90 and 100 or can be a vector of 0.95 and 0.998, for example, to output both 95 percent and 99.8 percent percent CIs; numeric; default 0.95

Value

When type = "full", returns a data.frame of value_sum, value_count, stdev, value, lowercl, uppercl, confidence, statistic and method for each grouping set

See Also

Other PHEindicatormethods package functions: assign_funnel_significance(), calculate_ISRate(), calculate_ISRatio(), calculate_funnel_limits(), calculate_funnel_points(), phe_dsr(), phe_life_expectancy(), phe_proportion(), phe_quantile(), phe_rate(), phe_sii()

Examples

library(dplyr)
df <- data.frame(values = c(30,40,50,60))

## default execution
phe_mean(df, values)

## calculate 95% and 99.8% CIs in single execution
phe_mean(df, values, confidence = c(0.95, 0.998))

## calculate multiple means in a single execution

df2 <- data.frame(area = rep(c("Area1", "Area2"),each=3),
                  values = c(20,30,40,200,300,400)) %>%
                  group_by(area)
phe_mean(df2,values)
phe_mean(df2,values,type="standard", confidence=0.998)



PHEindicatormethods documentation built on May 29, 2024, 12:20 p.m.