19 Practice
19.1 starwars
Excercises
Please use the starwars
dataset from the dplyr
package to answer the following questions:
- How may humans are in this dataset?
- How many characters are taller than 89 cm?
- How many characters are taller than 37 inches?
- How many characters are taller than 37 inches and weigh more than 55 pounds?
- How many characters are not human or droid?
- How many characters are not human or droid and are taller than 47 inches?
- Which species has the most individuals included in this data set?
- Which species has the tallest individuals on average?
- What is the tallest individual for each species?
- Calculate the BMI for each individual and determine which individual has the highest BMI. Use the formula
bmi = mass/((height/100)^2)
to calculate bmi. - Which homeworld has the most individuals included in this data set?
- Which homeworld has the tallest individuals on average?
- What is the tallest individual for each eye color?
19.2 iris
Excercises
Please use the iris
dataset from base R to answer the following questions:
- How many “virginica” have a petal width of 2.3 or greater in this dataset?
#> n
#> 1 14
- What is the average petal width for each species?
#> # A tibble: 3 × 2
#> Species avg.petal.width
#> <fct> <dbl>
#> 1 setosa 0.246
#> 2 versicolor 1.33
#> 3 virginica 2.03
- How many observations of each species have a petal width of 2.3 or greater in this dataset?
#> # A tibble: 1 × 2
#> Species n
#> <fct> <int>
#> 1 virginica 14
- How many observations of each species have a petal width of 0.5 or greater in this dataset?
#> # A tibble: 3 × 2
#> Species n
#> <fct> <int>
#> 1 setosa 2
#> 2 versicolor 50
#> 3 virginica 50
19.3 More practice
Using the flights
data answer:
- How many different destinations are in the flights data?
- Which destination has the most flights?
- How many origin airports are in the state of sick, and which has the most flights?
- Which month of the year has the most flights? The least?
- Which Carrier has the longest average flight?
- Which carrier has the most flights in the month of October leaving from Newark?
- What percentage of June flights arrive late?
- Which carrier has the most late flights in the month of December?
- This one is hard: for flights leaving JFK, which airline has the greatest percentage of late flights?
- Think of a question that you could ask about this data. What’s the question, and what’s the answer?
19.4 Yet more practice
Using the iris
data answer:
- How many flowers are species “virginica” and have a Sepal.Length greater than 7.5?
- Create a new variable called Sepal.Area with is:
Sepal.Area = Sepal.Width * Sepal.Length
- What is the maximum new Sepal.Area?
- Calculate the average Sepal.Area for each species and organize these values in descending order.
- Find the minimum Sepal.Area for each species and organize these values in descending order.
- How many flowers of each species have Sepal.Area of less than 15?
- What is the mean sepal length for flowers with a Sepal. Area of less than 15?