<- read_csv("https://bcdanl.github.io/data/NVDA.csv") nvda
Classwork 10
Working on variables with select()
, rename()
, and relocate()
; Adding a new variable with mutate()
Question 1. select()
; rename()
; and relocate()
Q1a.
- Brainstorm as many ways as possible to select
dep_time
,dep_delay
,arr_time
, andarr_delay
from flights.
Q1b.
- Rename
air_time
toair_time_min
to indicate units of measurement and move it to the beginning of the data frame.
Question 2. Add new variables with mutate()
Q2a.
- Currently
dep_time
andsched_dep_time
are convenient to look at, but hard to compute with because their values are represented with format HHMM or HMM (H for hour and M for minute).- Convert them to a more convenient representation of number of minutes since midnight.
Q2b.
- Compare
air_time
witharr_time - dep_time
. What do you expect to see? What do you see? What do you need to do to fix it?
Q2c.
- Compare
dep_time
,sched_dep_time
, anddep_delay
. How would you expect those three numbers to be related?
Q2d.
- Find the 20 most delayed flights using a ranking function. How do you want to handle ties?
Q2e.
- Read the following CSV file,
NVDA.csv
, as a data.frame with the namenvda
:
- Describe the distribution of the percentage change in
Close
price of Nvidia stock.
Q2f.
- Use the
gapminder
data.frame for Q2f:
# install.packages("gapminder")
library(gapminder)
<- gapminder::gapminder gapminder
- Provide the R code to create a dotplot that displays the values of
country
, sorted bylifeExp
within eachcontinent
for theyear
2007.
Q2g.
- Use the
gapminder
data.frame for Q2g. - Use the
gapminder
data.frame for Q2f:
# install.packages("gapminder")
library(gapminder)
<- gapminder::gapminder gapminder
- Provide the R code to describe a time trend of
lifeExp
for both North Korea and South Korea in one ggplot figure.