mySum {petersenlab}R Documentation

My Sum.

Description

Compute a row sum and retain NAs when all values in the row are NA.

Usage

mySum(data)

Arguments

data

dataframe

Details

Compute a row sum and set the row sum to be missing (not zero) when all values in the row are missing (NA).

Value

Modified row sum to set row sum to be missing when all values in the row are missing (NA).

See Also

Other computations: Mode(), meanSum()

Examples

# Prepare Data
df <- data.frame(item1 = rnorm(1000), item2 = rnorm(1000), item3 = rnorm(1000))
df[sample(1:nrow(df), size = 100), c("item1","item2","item3")] <- NA

# Calculate Missingness-Adjusted Row Sum
df$sum <- mySum(df)

[Package petersenlab version 1.0.0 Index]