any_by_row: Process by row or group

View source: R/any_by_row.r

any_by_rowR Documentation

Process by row or group

Description

if all NA then return NA, else run the aimed function

Usage

any_by_row(...)
mean_by_row(...)
sum_by_row(...)

Author(s)

Shanquan CHEN shanquan0301@gmial.com

Examples

# judge by row, need use mapply
dat_hl <- dat_hl %>% mutate(
  hearing = mapply(any_by_row, hearing_1, hearing_2),
  seeing = mapply(any_by_row, seeing_1, seeing_2),
  dis_comm_sup = mapply(mean_by_row, dis_comm_1, dis_comm_2)
  )

# judge by group, can use directly
mdat <- dat_all %>% group_by(unique_hh) %>% summarise(
  disability = any_by_row(disability_0_4, disability_5_7_without_mental, disability_adult))


shanquan0301/DataDescription documentation built on March 13, 2024, 2:49 a.m.