How to make a table of frequency with multiple response question

I have a data base with multiple response (colums tema1, tema2, tema3) that are coded, as show below:

tema1 tema2 tema3
25 6 14
25 4 11
25 2 5
11 8
25 6 18
2 1
25 6 14
21 6 4
25 6 14

I want to make a table of frequency like this

tema frequency
1 1
2 3
4 2
6 4

I´ll apreciete if you can help indicating wich comand or comands I have to use. Thanks.
Aldo.

I am not sure of the relationship between your original data and the frequency table. Do you want to see how many times each value occurs in the original data, like this?

library(tidyverse)
DF <- tribble(
  ~tema1, ~tema2, ~tema3,
  25, 6, 14,
  25, 4, 11,
  25, 2, 5,
  11, 8,NA,
  25, 6, 18,
  2, 1,NA,
  25, 6, 14,
  21, 6, 4,
  25, 6, 14
)

DF
#> # A tibble: 9 x 3
#>   tema1 tema2 tema3
#>   <dbl> <dbl> <dbl>
#> 1    25     6    14
#> 2    25     4    11
#> 3    25     2     5
#> 4    11     8    NA
#> 5    25     6    18
#> 6     2     1    NA
#> 7    25     6    14
#> 8    21     6     4
#> 9    25     6    14
DF <- DF |> pivot_longer(cols = everything())
DF
#> # A tibble: 27 x 2
#>    name  value
#>    <chr> <dbl>
#>  1 tema1    25
#>  2 tema2     6
#>  3 tema3    14
#>  4 tema1    25
#>  5 tema2     4
#>  6 tema3    11
#>  7 tema1    25
#>  8 tema2     2
#>  9 tema3     5
#> 10 tema1    11
#> # ... with 17 more rows
table(DF$value)
#> 
#>  1  2  4  5  6  8 11 14 18 21 25 
#>  1  2  2  1  5  1  2  3  1  1  6

Created on 2022-01-14 by the reprex package (v2.0.1)

Thanks, that was the idea. It will be very useful.

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.