Question

Use R to do the following. please provide the code Import the data set `UScereal`, create...

Use R to do the following. please provide the code

Import the data set `UScereal`, create a scatter plot of `calories` modeled by `sugars` using the `shelf` variable to create different plot characters.

Add a legend to indicate the shelf number. Is there any patterns? (Use base R plotting for this problem.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The R code is

library(MASS)

with(UScereal,plot(calories,sugars,pch=1:3,cex=1.2,col=1:3))

legend( "topright" ,legend=1:3,cex=1.2,pch=1:3,col=1:3) # Here 1:3 denotes shelf number in legend

The scatter plot show positive association pattern between calories and sugars

It will be show positive moderate correlation between the calories and sugars

Add a comment
Know the answer?
Add Answer to:
Use R to do the following. please provide the code Import the data set `UScereal`, create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help answer this question using R. Data sets are provided by putting in R. (will...

    Please help answer this question using R. Data sets are provided by putting in R. (will rate if answered by Tues 6/18) 5. 5.1 For the UScereal (MASS) data set, create a scatter plot of calories modeled by sugars using the shelf variable to create different plot characters. Add a legend to indicate the shelf number. Is there any pattern? 5. 5.1 For the UScereal (MASS) data set, create a scatter plot of calories modeled by sugars using the shelf...

  • Use matlab a) Create a simulated data set b) Create a set of plots to determine...

    Use matlab a) Create a simulated data set b) Create a set of plots to determine the best transformation to linearize the data c) Fit a first order polynomial (y mx + b) to the linearized data to find the constants m and b d) Reconstruct the original equation from m and b in the linear fitted polynomial e) Plot the fitted equation. Radioactive decay is modeled by the equation: rt where A the amount of mass as a function...

  • Exercise 1. For this exercise use the bdims data set from the openintro package. Type ?bdims to r...

    Exercise 1. For this exercise use the bdims data set from the openintro package. Type ?bdims to read about this data set in the help menu. Of interest are the variables hgt (height in centimeters), wgt (weight in kilograms), and sex (dummy variable with 1-male, 0-female). Since ggplotO requires that a categorical variable be coded as a factor type in R, run the following code: library (openintro) bdíms$sex2 <-factor (bdins$sex, levels-c (0,1), labels=c('F', 'M')) (a) Use ggplot2 to make a...

  • This uses MATLAB code with plotting HW19: Plotting with plot () Due 11:59 pm Monday 1....

    This uses MATLAB code with plotting HW19: Plotting with plot () Due 11:59 pm Monday 1. (10 pts) Write a script that will produce a sine curve and a cosine curve in the same plot, 0 as shown to the right. 06 0.4 0.2 To have two sets of data in one plot, you may plot the first one, then with the command hold on", plot the other. Or, you can learn how to plot two lines with just one...

  • 1. Which variables are ordinal? Which are nominal? Nominal variables: and Ordinal Variables: (although it is...

    1. Which variables are ordinal? Which are nominal? Nominal variables: and Ordinal Variables: (although it is coded as continuous) Answer Options: 1a. Nominal variables selections: Calories, Type, Protein or Potassium, MFG 1b. Ordinal Variables selections: Calories, Shelf, Protein 2. Use Cols>Columns Viewer to obtain summary statistics. Which, if any, of the variables is missing values? The variables , , and have missing values. The data set has missing values in total. Answer Options: 2a. Calories, Carbo, Protein & Fat 2b....

  • Write a R code for the following Using the SATGPA data set in Stat2Data package. Test...

    Write a R code for the following Using the SATGPA data set in Stat2Data package. Test by using α= .05. 1) Create the following three variables and then print out all the six variables. Create a new variable “SAT”, which is the sum of MathSAT and VerbalSAT. Create second new variable “SATLevel”, and assign the value of “SATLevel” as 1 when SAT<=1100, 2 when 11001300. Create third new variable “GPALevel” and assign the value of “GPALevel” as 1 when GPA<=2.8,...

  • NEED R CODE PLEASE ## Problem 4 *For the `homedata` (**UsingR**) data set find 90% confidence...

    NEED R CODE PLEASE ## Problem 4 *For the `homedata` (**UsingR**) data set find 90% confidence intervals for both variables `y1970` and `y2000`, assuming the sample represents some population. Perform one sample t-test for each variable, use `t.test()`, but first discuss whether the model assumptions are appropriate (include some check of the assumptions, like a Q-Q plot).*

  • Using program R, please help solve: Data set is given in program R and can be seen by putting in code: state.x77 x77<...

    Using program R, please help solve: Data set is given in program R and can be seen by putting in code: state.x77 x77<-data.frame(state.x77) (if answered by Tuesday 6/11 evening, I will rate) 3.17 The state.x77 data set contains various information for each of the fifty United States. We wish to explore possible relationships among the variables. First, we make the data set easier to work with by turning it into a data frame. x77data.frame(state.x77) ; Now, make scatter plots of...

  • To import the Auto dataset into Rstudio: library("ISLR") data(Auto) view(Auto) Then, provide necessary codes for the...

    To import the Auto dataset into Rstudio: library("ISLR") data(Auto) view(Auto) Then, provide necessary codes for the following: a. Create a binary variable FuelEfficient that takes on the value Yes or 1 if mpg is greater than 25 and takes on the value No or 0 if mpg is less than, or equal to, 25. b. Split the data into a training set and a test set. c. Fit a tree to the training data with FuelEfficient as the response variable....

  • please do this problem in matlab and show me the code. Thanks. please do this problem...

    please do this problem in matlab and show me the code. Thanks. please do this problem in matlab and show me the code. Thanks. please do this problem in matlab and show me the code. Thanks. please do this problem in matlab and show me the code. Thanks. please do this problem in matlab and show me the code. Thanks.please do this problem in matlab and show me the code. Thanks. please do this problem in matlab and show me...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT