I'm facing the following problem: I need to create a graph and a table with information about scholarity and profession for different years and regions (7 years and 5 regions).
I have 4 levels of scholarity (fundinc, medioinc, superiorinc and supdout) and 3 levels of profession (apoio, operacional and estrategico).
Each level is a column (if fundinc == 1, the others are 0, and if apoio == 1, operacional and estrategico are both 0).
The data base is separated by year and region (data2010nordeste, data2010norte, data2010centro, data2010sudeste, data2010sul, ..., data2016nordeste, data2016norte, data2016centro, data2016sudeste, data2016sul).
The db's is something like:
fundinc | medioinc | superiorinc | supdout | apoio | operacional | estrategico
1 | 0 | 0 | 0 | 1 | 0 | 0
0 | 1 | 0 | 0 | 0 | 1 | 0
0 | 0 | 1 | 0 | 0 | 0 | 1
0 | 0 | 1 | 0 | 0 | 0 | 1
0 | 1 | 0 | 0 | 1 | 0 | 0
1 | 0 | 0 | 0 | 1 | 0 | 0
.
.
.
Any suggestion ? I'm totally lost.
I tried to create a function:
pegaescolaridadeapoio = function (base) {
#Fundamental incompleto
a <- base[base$fundinc==1 & base$apoio==1, ]
#Medio incompleto
b <- base[base$medioinc==1 & base$apoio==1,]
#Superior incompleto
c <- base[base$superiorinc==1 & base$apoio==1,]
#superior e outros
d <- base[base$supdout==1 & base$apoio==1,]
vetor <- c(nrow(a),nrow(b),nrow(c),nrow(d))
return (vetor)
}
And some vectors to put it on a graph / table, but I had no success.