1
Hello,
I have a data set sinan18
that contains information about food outbreaks in Brazil. Formatting the original table - which is huge with dplyr, I arrived at the following result:
> str(sinan18)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 13163 obs. of 8 variables:
$ estado : chr "DF" "RS" "RS" "RS" ...
$ regiao : Factor w/ 5 levels "Centro-Oeste",..: 1 5 5 5 5 5 5 5 5 5 ...
$ data : chr "05/05/2000" "22/05/2000" "22/05/2000" "22/05/2000" ...
$ ano : int 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 ...
$ agente1 : chr "Ignorado" "Salmonella spp." "Salmonella spp." "Ignorado" ...
$ agente2 : chr "" "" "" "" ...
$ alimento: chr "Alimentos mistos" "Ovos e produtos à base de ovos" "Ovos e produtos à base de ovos" "Ovos e produtos à base de ovos" ...
$ local : Factor w/ 13 levels "Asilo","Casos dispersos em mais de um município",..: 6 12 12 12 12 12 10 12 12 12 .
sinan18 %>%
group_by(agente1)%>%
count(regiao)
1 " Cryptosporidium" Sudeste 12
2 Adenovírus Nordeste 2
3 Adenovírus Sudeste 2
4 Aeromonas Nordeste 2
5 Aeromonas Sudeste 5
6 Aeromonas Sul 2
7 "Aeromonas hidrophila " Nordeste 1
8 "Aeromonas hidrophila " Sudeste 1
9 Aeromonas spp. Nordeste 3
10 Amebíase Sul 1
However, I need to consolidate a table where the regions are the variables (columns) and the microorganisms the observations (rows). How do I do it?
Hello, use the command
dput(sinan18)
to take a sample of your data, and edit your topic, so it will be easier to understand your question and test in your data.– Thiago Fernandes
Are you looking for (OS in English)?
– Rui Barradas