How to plot "No Response" values in survey data?

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.

#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#>     chisq.test, fisher.test
  ~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.
#> # 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)

we have no context but probably

# fixed typo : ng <- pivot_longer(no_response,cols = -enumerator)

nr_long <- pivot_longer(no_response,cols = -enumerator)

ggplot(nr_long) +
geom_col() + 
facet_wrap(~enumerator,ncol = 1)

We have done a survey where we test students. I wanted to know enumerator-wise, on an average, how many no response values are coming. This is done to ensure we have good quality data.

The code that you have sent does not work.

I apologise, I had a type in my code wher i wanted to make nr_long from pivot_longer but had it as ng by mistake. I'll edit it

I get a better result under assumptions that you want your no response dataset to return the ratio of 98L values to all values per column.

no_response<-data %>%
  group_by(enumerator) %>%                                     
  summarize(across(.cols = everything(),~sum(.==98)/n()))

That's ok. I knew it was a typo.. Thanks for your support..

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.