讀入pokemon資料
pokemon <- read.csv(“Pokemon.csv”)
type1 <- unique(pokemon$Type.1)
print(type1)
[1] "Grass" "Fire" "Water" "Bug" "Normal"
[6] "Poison" "Electric" "Ground" "Fairy" "Fighting"
[11] "Psychic" "Rock" "Ghost" "Ice" "Dragon"
[16] "Dark" "Steel" "Flying"
table(pokemon$Type.1)
Bug Dark Dragon Electric Fairy Fighting
69 31 32 44 17 27
Fire Flying Ghost Grass Ground Ice
52 4 32 70 32 24
Normal Poison Psychic Rock Steel Water
98 28 57 44 27 112
avg_legendary <- aggregate(Total ~ Legendary, data = pokemon, FUN = mean)
print(avg_legendary)
Ans:legendary Pokémon higher than non-legendary
Legendary Total 1
False 417.2136 2
True 637.3846
water_pokemon <- subset(pokemon, Type.1 == “Water”)
top5water <- water_pokemon[order(water_pokemon$Total, decreasing = TRUE), ]
tp5water <- head(top5water, 5)
print(tp5water[, c(“Name”, “Total”)])
Ans:在水屬性中,總屬性值最高的分別是KyogrePrimal Kyogre、
Palkia、Kyogre、GyaradosMega Gyarados、SwampertMega Swampert