I have a dataframe as df with the following columns:
df <- data.frame(
years = c(2010, 2010, 2011, 2011),
category = c("Category1", "Category2", "Category1", "Category2"),
type = c("Type1", "Type2", "Type1", "Type2"),
theme = c("Theme1", "Theme2", "Theme1", "Theme2"),
count = c(40, 50, 10, 70)
)
I would like to make a table like this in R:
Category1 Category2
2010 | 2011 2010 | 2011
Type1
Theme1 x x x x
Type2
Theme2 x x x x
Where x is the average count number per year per category per type and per theme.
Any ideas on how to do this?
This will not be exactly the same, but you could use the table1 package to get something similar to what you are looking for.