Review
A student needs help with their project in R and you are going to assist them! Answer their questions below. If you get stuck, you can view the answers here.
Required dataset: wbi_r.csv
- I need to use dplyr. How do I load it?
- How do I load my csv file into a data frame?
- How do I list the variables I have in my dataset?
- How do I list rows 20 through 30 for the first 5 columns?
- How do I get a subset that includes only data from the year 2010?
- How do I subset my 2010 data so that I only have two columns: countries and mobile phone subscriptions?
- How do I tell R that the blanks in that subset represent missing values?
- How do I remove countries with missing data from that subset?
- How do I order the countries in that subset by highest number of mobile phone subscriptions to lowest?
- Maybe China’s high mobile phone subscriptions are a result of their high population. How can I add the population information back in? HINT: I need to MERGE my old dataframe with my new dataframe.
- Now I want to get phone subscriptions per capita. How do I write a function to do that in base R?
- How do I apply the function?
- What’s a simpler way to apply the same function using dplyr?
- Let’s use the dplyr created dataframe. How do I sort by mobile phone subscriptions per capita, also using dplyr this time?
- I want to add another column to my dataframe that has 3 categories: “More phones than people”, “One phone per person”, and “Fewer phones than people”. How do I do that?
- Now I’m interested in life expectancy over time. Using dplyr on my original dataframe, how can I get the average universal life expectancy for both males and females by year?
- I have a hunch that we can predict internet users by urban population. How do I fit a linear model?
More Exercises