What are the first 10 rows of the dataset? What are the last 7 rows?
Process:
first_10 <-head(pkm,10)last_7 <-tail(pkm,7)#Answer:#The first 10 rows:first_10
# A tibble: 10 × 29
id set series publisher generation release_date artist name set_num
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 base1-1 Base Base WOTC First 1/9/1999 Ken Su… Alak… 1
2 base1-2 Base Base WOTC First 1/9/1999 Ken Su… Blas… 2
3 base1-3 Base Base WOTC First 1/9/1999 Ken Su… Chan… 3
4 base1-4 Base Base WOTC First 1/9/1999 Mitsuh… Char… 4
5 base1-5 Base Base WOTC First 1/9/1999 Ken Su… Clef… 5
6 base1-6 Base Base WOTC First 1/9/1999 Mitsuh… Gyar… 6
7 base1-7 Base Base WOTC First 1/9/1999 Ken Su… Hitm… 7
8 base1-8 Base Base WOTC First 1/9/1999 Ken Su… Mach… 8
9 base1-9 Base Base WOTC First 1/9/1999 Keiji … Magn… 9
10 base1-10 Base Base WOTC First 1/9/1999 Ken Su… Mewt… 10
# ℹ 20 more variables: types <chr>, supertype <chr>, subtypes <chr>,
# level <chr>, hp <dbl>, evolves_from <chr>, evolves_to <chr>,
# abilities <chr>, attacks <chr>, weaknesses <chr>, retreat_cost <chr>,
# converted_retreat_cost <dbl>, rarity <chr>, flavor_text <chr>,
# national_pokedex_numbers <chr>, legalities <chr>, resistances <chr>,
# rules <chr>, regulation_mark <chr>, ancient_trait <chr>
Do a very quick exploratory histogram of types of Pokémon. Is this visualization useful?
Process:
hist(table(pkm$types))
ggplot(pkm,aes(x = types))+geom_bar()
Answer:
This graph is not valuable, because the most types have the same amount of frequency.And it just shows the count of each type. The graphs does not really show any trend.
Question 10
Freestyle: Search for something else with the data! What did you find?
Process: I would like to visualize the relationship between hp and level.
Even if the diagram doesn’t look pretty, there is a little trend that the higher the level is, the higher the hp would be. And the highest level has the highest hp Pokémon.
Data Wrangling assignment
Question 1 - Question 2
There are a ton of variables, but we don’t want that many. Make a new data frame or table containing only the following variables. You can choose to make a new one or drop the rest of the columns using drop function. Include these variables:Generation , release_date, Artist, Name, Types, supertypes, Hp, evolvesFrom, evolvesTo, Nationalpokedexnumbers
Show the last 10 rows of your new table or data frame.
Go back to the (non-null) dataframe and wrangle the data to eliminate non-Pokémon supertypes in your data frame. Check to see if you have only pokemon supertypes now.
Great! Now that we only have pokémon, delete the supertype column. After deleting it, check to see if we have any null values in hp. (That would be an issue if our pokémon have no hp :o). What did you find?
Process:
pkm$supertype <-NULLsum(is.na(pkm$hp))
[1] 0
Answer:
There is no null values in hp.
Question 8
Notice the generation variable. What type of data is that (nominal, ordinal, ratio, etc)? What type of data is it in the data frame (int, float, string,..)? What unique values do we have?
Raichu’s hp was only enhanced in generation 2 and 3. From generation 4, it went back to 80 from 90. I guess it may because of the game balance.
Poke-Visualizations
Univariate1
ggplot(pkm,aes(x = generation_int))+geom_bar()+labs(titles ="The number of pokemons created in every generation",x ="Generation",y ="Number of card")+scale_x_continuous(breaks =c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),labels =c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))
The bar plot shows that the most number of pokemons were created in generation 8.According to the trend of this diagram, I speculate that for the next few years, there may be a pokemon production rise.
Univariate2
pkm |>ggplot(aes(x = hp))+geom_bar()+labs(titles ="The number of pokemons in each HP levels",x ="HP of pokemons",y ="Number of pokemon")
The graph shows the number of pokemons in each HP levels. Most of pokemon have hp lower than 150 or so. The diagram is right-skewed, which means higher HP, less number of pokemon.
Bivariate1
pkm |>ggplot(aes(x = generation_int,y = hp))+geom_point()+scale_x_continuous(breaks =c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),labels =c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))+labs(title ="The relationship between the generation and pokemons' hp",x ="Generation",y ="HP of Pokemons")
The diagram gives the relationship between generationa and the HP of Pokemons. As the diagram shown, the company creates the highest hp pokemon in generation eight and nine.
The graph shows the relationship between the generation and the average of pokemons’hp. As the diagram shown, the company designed the most high hp pokemons in generation 8. Based on the graph, I speculate that the company will keep designing low hp pokemons to compensate for the lack of low hp pokemon.