I want to get the "No response" ratio enumerator-wise. The following code does not give it in the required form. Pls help me out.
library(tidyverse)
library(janitor)
#>
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#>
#> chisq.test, fisher.test
data<-tibble::tribble(
~enumerator, ~l1el3_total, ~l1el4_identify_letter1, ~l1el4_identify_letter2, ~l1el4_identify_letter3, ~l1el4_identify_letter4, ~l1el4_identify_letter5, ~l1el4_total,
"PEN008", 6L, 98L, 98L, 98L, 98L, 98L, 0L,
"PEN001", 6L, 1L, 0L, 0L, 0L, 1L, 2L,
"PEN006", 6L, 1L, 1L, 1L, 1L, 1L, 5L,
"PEN006", 1L, 2L, 1L, 1L, 1L, 1L, 98L,
"PEN010", 4L, 98L, 98L, 98L, 98L, 98L, 0L,
"PEN010", 0L, 98L, 98L, 98L, 98L, 98L, 0L,
"PEN003", 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"PEN003", 6L, 0L, 0L, 0L, 0L, 0L, 0L
)
no_response<-data %>%
group_by(enumerator) %>%
summarize_each(funs(sum(data[sapply(data, is.numeric)] == 98)))
#> Warning: `summarise_each_()` was deprecated in dplyr 0.7.0.
#> Please use `across()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> Warning: `funs()` was deprecated in dplyr 0.8.0.
#> Please use a list of either functions or lambdas:
#>
#> # Simple named list:
#> list(mean = mean, median = median)
#>
#> # Auto named with `tibble::lst()`:
#> tibble::lst(mean, median)
#>
#> # Using lambdas
#> list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
no_response
#> # A tibble: 5 x 8
#> enumerator l1el3_total l1el4_identify_le~ l1el4_identify_le~ l1el4_identify_l~
#> <chr> <int> <int> <int> <int>
#> 1 PEN001 16 16 16 16
#> 2 PEN003 16 16 16 16
#> 3 PEN006 16 16 16 16
#> 4 PEN008 16 16 16 16
#> 5 PEN010 16 16 16 16
#> # ... with 3 more variables: l1el4_identify_letter4 <int>,
#> # l1el4_identify_letter5 <int>, l1el4_total <int>
Created on 2021-10-29 by the reprex package (v2.0.1)