lhd_rowMean: Calculates row missing with means coded to NA based on number...

Description Usage Arguments Value Examples

View source: R/lhd_rowMean.R

Description

Calculates row missing with means coded to NA based on number of missing variables.

Usage

1
lhd_rowMean(data, newvar, vars, num_miss)

Arguments

data

the tibble or data.frame.

newvar

is the name of the new variable.

vars

is the vector of variable names that will be used to calculate the row mean.

num_miss

is the number of missing that will be used to determine if the row mean should be missing. It is expressed as >=. Therefore, if num_miss == 2, the variable would be coded to NA if 2 or more variables in the list are missing.

Value

The tibble or data.frame with the row mean and the number of missing across the variable list.

Examples

1
2
3
4
5
6
7
library(RLifeHD)
library(tidyverse)
master <- tibble(x = c(1:5, NA,NA), y = c(1,2,3,4,NA, NA,7))
master
vars <- c("x", "y")
master <- lhd_rowMean(master, my_row_mean, vars, 1)
master

JECheadle/RLifeHD documentation built on July 22, 2020, 3:10 p.m.