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?