Carregar pacotes ggplot2 e MASS e carregar dataframe Cars93.
library(ggplot2)
library(MASS)
View(Cars93)
ggplot(Cars93, aes(x=Type)) + geom_bar() + labs(y = "Frequency", title = "Car Type and Frequency in Cars 93")
Exemplos
library(ggplot2)
library(gapminder)
data(gapminder)
head(gapminder)
## # A tibble: 6 x 6
## country continent year lifeExp pop gdpPercap
## <fct> <fct> <int> <dbl> <int> <dbl>
## 1 Afghanistan Asia 1952 28.8 8425333 779.
## 2 Afghanistan Asia 1957 30.3 9240934 821.
## 3 Afghanistan Asia 1962 32.0 10267083 853.
## 4 Afghanistan Asia 1967 34.0 11537966 836.
## 5 Afghanistan Asia 1972 36.1 13079460 740.
## 6 Afghanistan Asia 1977 38.4 14880372 786.
gapminder2<- subset(gapminder, continent=="Americas" & year==2007)
ggplot(gapminder2, aes(x=country, y=lifeExp))+
geom_col(fill = "dodgerblue") +
labs(title = "Expectativa de vida por país",
subtitle = "2007",
x = "País",
y = "Anos")+
theme(axis.text.x = element_text(angle = 30, hjust = 2))
Referências
Schmuller, Joseph. Análise Estatística com R - Para leigos - Tradução da 2a edição. Alta Books Editora. 2019.
Oliveira, Paulo; Guerra, Saulo; McDonnell, Robert. Ciência de Dados com R. Introdução.Editora IBPAD. Brasília. 2018. Disponível em: {https://cdr.ibpad.com.br/cdr-intro.pdf}