I want to create a neat table in R markdown using the kable package, but my data need to be transformed.
My data look like this:
category <- c('population', 'population', 'sample', 'sample', 'population', 'population', 'sample', 'sample')
gender <- c('female', 'male', 'female', 'male', 'female', 'male', 'female', 'male')
n <- c(12,20,14,14,11,21,13,15)
frequency <- c(0.375, 0.625, 0.5, 0.5, 0.34375, 0.65625, 0.4642857, 0.5357143)
cohort <- c('one', 'one', 'one', 'one', 'two', 'two', 'two', 'two')
df <- data.frame(category, gender, n, frequency, cohort)
I would like to create a table in R markdown that looks like this (but I welcome other suggestions):
Any ideas on how to solve this? I appreciate any help!