Linguagem R:Gráficos
Índice
Gráficos Básicos do R
Plot
plot(=nome da variável=)
Gráfico pontos
c <- c(3991,1059,493,287,184,131,113,85,64,65,41,47,32,28,21) plot(c)
Gráfico linha =
c <- c(3991,1059,493,287,184,131,113,85,64,65,41,47,32,28,21) plot(c,type="l")
c <- (10,20,30,20,14,30) freq <- table(c) plot(freq)
# ORDENAR DO MAIOR PARA O MENOR freq <- sort(freq, decreasing=TRUE) plot(freq)
Legenda na Vertical
par(las=1) plot(freq)
Dispersion
Dados padrão do R para exemplos
# Cria um modelo de dados my_data <- mtcars
# Mostra as seis primeiras linhas head(my_data, 6)
plot(x = my_data$wt, y = my_data$mpg,
pch = 16, frame = FALSE,
xlab = "wt", ylab = "mpg", col = "#2E9FDF")
Bar Plot
barplot(=nome da variável=)
GGPLOT2
Pacotes
# Installation
install.packages('ggplot2')
# Loading
library(ggplot2)
[1]
Salvando gráfico em arquivo
PNG
Temperature = c(15,15,15,15,20,21,12,32,23,33,32,19,54) png(file="d:/lixo/saving_plot2.png", width=600, height=350) hist(Temperature, col="gold") dev.off()