• What is an R package? How to install a package in R? How to use a function contained in a package? • We have been using the dplyr functions such as arrange(), filter(), select(), mutate(), and summarise(). What is each of them for? • How to use ggplot() function to visualize data?
Added by Kate M.
Close
Your feedback will help us improve your experience
Sanchit Jain and 93 other Intro Stats / AP Statistics educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
# Install the package if you have not installed it before ("ggplot2") # Load the package library (ggplot2) Load the mpg dataset data ("diamonds") Problem 1 (1 x 5 = 5 points) Use ggplot2 to visualize the data. You need to paste the resulting plots and related code in order to get the full points. For each ggplot plot: • make it complete/readable, in other words, it should include axis label(s), title, and legend if necessary; • write 1-2 sentences about what the chart tells you about the data. (a) Choose bin number or binwidth (Hint: See page 11 of lecture_04c.pdf), explain why; and create a histogram of carat. (b) Make a scatter plot of y = price against x = carat and set the color to clarity. (c) Make a scatter plot of y = price against x = carat and add a smooth line to each group of points defined by clarity. (d) Make a scatter plot of y = price against x = carat and facet it by clarity. (e) Show carat VS cut, make a point, jitter, box plot, and a violin plot, respectively. Which one is the best for visualization?
Sri K.
In Section 5.3 of our textbook, the merge() function only works when all kids appearing in d1 also appear in d2. Use the following vectors to complete this problem of merging frames: d1.Kids <- c("Jack", "Jill", "Jillian", "John", "James") d1.States <- c("CA", "MA", "DE", "HI", "PA") # construct d1 as a dataframe using d1.Kids and d1.States d1 <- data.frame(Kids = d1.Kids, States = d1.States) d2.Ages <- c(10, 7, 12, 30) d2.Kids <- c("Jill", "Jillian", "Jack", "Mary") # construct d2 as a dataframe using d2.Ages and d2.Kids d2 <- data.frame(Ages = d2.Ages, Kids = d2.Kids) You need to construct two dataframes and merge them. For missing data, please use NA as the value for the output. The output must display the content of d1, d2, and the result of merging d1 and d2. Hint: check the usage of set operations union() and match() or %in% operator. You cannot use merge(x,y,all) or any form of merge(). The output should look like the following: kids ages states 1 Jack 12 CA 2 Jill 10 MA 3 Jillian 7 DE 4 John NA HI 5 James NA PA 6 Mary 30 NA If you cannot figure out how to do this, you may use merge() for the highest score of 10/25. Write a program in R to generate a list containing the following information: Your first name, Your last name, Your Age, Your favorite movie (only one). Do the same for three close friends, and then write a program to answer the following questions: (a) What is the mean age of the moviegoers for each movie? (b) How many people are there in each family identified by the same last name? You are not allowed to use any loop or if-statements. Hint: You can hard code the list as my.list. You can create a dataframe using data.frame(name=c("A", "B"), age=c(15,20)). Draw the curve f(α) = (α^2 + 1)^0.5 for t between 0 and 5. You must use the Mathematical Markup Language (MML) to annotate your graphic. You need to add parameters: xlab, ylab, and main correctly. Hint: The function curve() requires to use x in the first argument instead of α.
Which command in R to make a plot of the data and then add the regression line of the two random variables x and y?
Recommended Textbooks
Elementary Statistics a Step by Step Approach
The Practice of Statistics for AP
Introductory Statistics
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD