0
I am using Rstudio and would like to transform a table that is in this format
municipality | affiliated to entities |
---|---|
Antoinina | yes |
Antonina | nay |
Antonina | Not |
Antonina | yes |
Antoinina | NI |
Paranaguá | nay |
Paranaguá | yes |
Paranaguá | nay |
Paranaguá | NI |
Paranaguá | NI |
Paranagua | NI |
Paranaguá | yes |
in a table in this format
Municipality | Yes | Not | NI |
---|---|---|---|
Antonina | 2 | 2 | 1 |
Paranaguá | 2 | 2 | 3 |
what I need is the categorical answers in column two to be counted differently, each category is a new column and quantities of answers ( yes/no/NI), or pointed by municipality. have tried almost everything I found rerefencia in the available tutorals of the network,
the closest I got was
saida <-c.socio %>%
mutate(sim= sum(Filiado.a.entidades.=="Sim"),
não= sum(Filiado.a.entidades.=="Não" ))%>%
group_by(Município)%>%
summarise(Filiado.a.entidades. = n())
but the result does not come out as expected, I only managed to group the answers by municipality in a single column, I could not separate the different categories of answer in different columns. Has anyone ever done anything like that? I hope I’ve been very clear