40 lines
887 B
R
40 lines
887 B
R
# data: 2023-10-25
|
|
|
|
library(data.table)
|
|
library(tidyr)
|
|
library(dplyr)
|
|
library(ggplot2)
|
|
|
|
# Nota: iniciar uma sessão de R desde o diretório "script" para carregar a tabela com o seguinte caminho relativo ("../data/Tabela4.csv"):
|
|
|
|
Evol_exist <- fread("../data/Tabela4.csv", check.names=FALSE, header=TRUE)
|
|
|
|
str(Evol_exist)
|
|
|
|
# Transpor a tabela
|
|
|
|
Evol_exist1 <- dcast(melt(Evol_exist, id.vars = "Ano"), variable ~Ano)
|
|
|
|
# deu um trabalho para n ão aparecer uma linha nova com os nomes da colunas...
|
|
|
|
str(Evol_exist1)
|
|
|
|
Evoluc <- Evol_exist1 %>%
|
|
pivot_longer(!variable, names_to="Categoria", values_to="Cabecas") %>%
|
|
dplyr::mutate(Ano=variable)
|
|
|
|
#View(Evoluc)
|
|
str(Evoluc)
|
|
|
|
Evoluc <- ggplot(Evoluc, aes(x=Ano, y=Cabecas, group = Categoria)) +
|
|
geom_line (aes(color=Categoria)) +
|
|
geom_point(aes(color=Categoria))
|
|
|
|
getwd()
|
|
|
|
png(filename = "fig/Evoluc1.png")
|
|
|
|
plot(Evoluc)
|
|
|
|
Evoluc
|