Project 1 – The Layered Grammar of Graphics and Package “ggplot2” Step 1: Execute the following commands in the RStudio console: > library(ggplot2) > data(package = “ggplot2”) This returns a list of...

1 answer below »
pfa


Project 1 – The Layered Grammar of Graphics and Package “ggplot2” Step 1: Execute the following commands in the RStudio console: > library(ggplot2) > data(package = “ggplot2”) This returns a list of datasets that reside in the ggplot2 package. Step 2: Select a dataset from the list, and study the data: Number of variables and observations Variable names and definitions You can google on “package ggplot2” or “datasets contained in ggplot2” for more information Step 3: Explore your data by plotting various combinations of data in various ways. Create new variables with mutate() if necessary. Run any kind of statistics you see fit. Run regressions using function lm(). Step 4: Select the most interesting graphics that you generated during your exploration (minimum of 4), and write a summary interpretation of your findings using Microsoft Word. Use the snipping tool in Windows to create png files of your graphs and insert them into your Word document. 2
Answered 3 days AfterMar 13, 2021

Answer To: Project 1 – The Layered Grammar of Graphics and Package “ggplot2” Step 1: Execute the following...

Smita Balasaheb answered on Mar 17 2021
153 Votes
Project 1 – The Layered Grammar of Graphics and Package “ggplot2”
Step 1:
Execute the following commands in the RStudio console:
> library(ggplot2)
> data(package = “ggplot2”)
This returns a list of datasets that reside
in the ggplot2 package.
> #install.packages("ggplot2")
> library(ggplot2)
> data() # This returns a list of datasets that reside in the ggplot2 package


Step 2
> data(trees)
> help(trees)
> data=trees
> str(data)
'data.frame': 31 obs. of 3 variables:
$ Girth : num 8.3 8.6 8.8 10.5 10.7 10.8 11 11 11.1 11.2 ...
$ Height: num 70 65 63 72 81 83 66 75 80 75 ...
$ Volume: num 10.3 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 ...
Study of the data:
In this data there are 3 variables and 31 observations
Variable names
1. Girth: Tree diameter in inches
2. Height: Height of the trees in ft
3. Volume of timber in Cubic ft
Step 3
Now we visualize our data using Scatter Plot
> scatter.smooth(data$Girth, data$Height)

Interpretation: From the above scatter plot of girth and height we can conclude that most of
the points are scattered but some points move from left to right, hence there is weak positive
relation between Girth and Height.
> scatter.smooth(data$Girth, data$Volume)


Interpretation: In this scatter plot of Volume and Girth we see that the data move from left to
right it results in if the Girth of Trees increases then volume of the tree also increases. Hence
there is positive relationship between Girth and Volume.
> scatter.smooth(data$Height, data$Volume)

Interpretation: From the above scatter plot of height and volume we can conclude that most
of the points are scattered but some points move from left to right, hence there is weak
positive relation between Volume and Height.
Now we see the correlation between the variables

> cor(data)
Girth Height Volume
Girth 1.0000000 0.5192801 0.9671194
Height 0.5192801 1.0000000 0.5982497
Volume 0.9671194 0.5982497 1.0000000
> library(GGally)
> ggpairs(data, columns=1:3, title="Trees")

Interpretation: Here we see that there is strong correlation between the Girth and Volume.
Now we check the normality of the data
> shapiro.test(data$Girth) # p> 0.05 assume data is normally...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here