load("C:/Users/Hp/Desktop/Base_de_dados-master/CARROS.RData")
load("C:/Users/Hp/Desktop/Base_de_dados-master/df_pokemon.RData")
aqui vamos ver o tipo de variável.
names(df)
## [1] "id" "pokemon" "species_id" "height"
## [5] "weight" "base_experience" "type_1" "type_2"
## [9] "attack" "defense" "hp" "special_attack"
## [13] "special_defense" "speed" "color_1" "color_2"
## [17] "color_f" "egg_group_1" "egg_group_2" "url_image"
## [21] "x" "y"
class(df$attack)
## [1] "integer"
class(CARROS$Preco)
## [1] "numeric"
class(df$type_1)
## [1] "character"
class(CARROS$Tipodecombustivel)
## [1] "numeric"
Aqui vamos modificar o tipo.
df$type_1 <- as.factor(df$type_1)
class(df$type_1)
## [1] "factor"
CARROS$Tipodecombustivel<-as.factor(CARROS$Tipodecombustivel)
class(CARROS$Tipodecombustivel)
## [1] "factor"
primeiros resultados.
tabela_pokemon<-table(df$type_1)
tabela_carros<-table(CARROS$Tipodecombustivel)
tabela_pokemon
##
## bug dark dragon electric fairy fighting fire flying
## 63 28 24 36 17 25 46 3
## ghost grass ground ice normal poison psychic rock
## 23 66 30 23 93 28 46 40
## steel water
## 22 105
tabela_carros
##
## 0 1
## 18 14
Aqui vamos criar três gráficos de barra.
barplot(tabela_pokemon, las=2, col="red",
main="solução 1")
par(cex=0.7)
barplot(tabela_pokemon,col="blue",
main="solução 2")
barplot(tabela_carros,col="orange")
```