I am trying to tabulate df dataframe using three variables using tabular from the tablespackage. The format of the result is OK but I don't understand why the values are all equal to 1 instead of using the values variable (frequency).
library(tidyverse)
library(tables)
df <- tibble(UT = c(rep(1, 9), rep(2,9)),
sex = rep(c(rep('MF', 3), rep('M', 3), rep('F', 3)),2),
age = rep(c('a','b','c'), 6),
values = c(1:18))
df <- df %>%
mutate(across(c(UT, sex, age), as.factor))
tabular(UT ~ (age * sex), data=df)
#>
#> age
#> a b c
#> sex sex sex
#> UT F M MF F M MF F M MF
#> 1 1 1 1 1 1 1 1 1 1
#> 2 1 1 1 1 1 1 1 1 1
Created on 2022-09-22 with reprex v2.0.2