View source: R/aggregateScale.R
aggregateScale | R Documentation |
Calculates the mean or sum of each row of a dataframe using rowMeans()
while applying a condition to only aggregate rows where missingess is below a certain threshold.
aggregateScale(dataframe, aggregate = "SUM", NA.threshold = 0.5, na.rm = TRUE)
dataframe |
A dataframe containing numeric scores to be aggregated. Each row should correspond to one observation. Each column is one variable. |
aggregate |
Defaults to |
NA.threshold |
The maximum proportion of missingness allowed for one observation/row before the aggregate score is coerced to NA. Defaults to 0.5, which means that rows with NA in more than half of its observation will have an NA aggregate score. |
na.rm |
Whether missing values should be ignored in the calculation for the aggregate scores. Defaults to |
mydata <- data.frame(a = c(1:8,NA,NA), b = 1:10, c = rep(NA,10))
aggregateScale(mydata)
aggregateScale(mydata, NA.threshold = 0.2) # less than 0.2 missingness
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.