Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Requirements In this project you will learn to create data visualizations in R,

ID: 3216249 • Letter: R

Question

Requirements In this project you will learn to create data visualizations in R, an open source software environment for statistics computing and graphics. For more information on R, visit this page, which contains links to many R tutorials R comes with its own GUI, but you may use other R GUIs such as RStudio 1. You need to install the following data sets in R. Data set name in R Description of OFP States Name Data Package the data set Ecdat link Visits to Physician Office Education and carData Related Statistics for the US States US Car Price Data Data from GapMinder.org web site DAAG carprice link gapminder gapminder link To download a data set, you need to do the following in R: install.packages("DAAG") library(DAAG) OFP carprice 2. You need to use the package lattice. You also need to install the package ggplot2 3. (25 points) Use the basic R graphics functions to create the following charts a. A bar chart showing the life expectancy for the United States over the years. (Data source: gapminder) b. A line chart showing the GDP of the United States over the years. (Data source: gapminder) c. A histogram showing MPG.city. (Data source: carprice)

Explanation / Answer

Install the required libraries

library(Ecdat)
library(carData)
library(DAAG)
library(gapminder)
require(Ecdat)
require(carData)
require(DAAG)
require(gapminder)
View(gapminder)

Solution2:

install.packages("lattice")
library(lattice)
require(lattice)
install.packages("ggplot2")
library(ggplot2)

require(ggplot2)

Solution3A;

To filter only US Data us ethe below R code:

Code :

gapminderbycountry <- filter(gapminder, country %in% c("United States"))
gapminderbycountry
attach(gapminderbycountry)
dim(gapminderbycountry)

#to get barchart execute below code

p <- ggplot(gapminderbycountry, aes(x= year, y=lifeExp))
p + geom_bar(stat = "identity")

Intrepretation:

we have seen increasing trend of life expectancy from 1952 to 2007

Solution3b:

Rcode is:

q <- ggplot(gapminderbycountry, aes(x= year, y=gdpPercap))
q + geom_line(stat = "identity")

Intrepretation:

We have gdpPercap increases linearly with time

Solution3c:

Rcode :to get the histogram execute below code:

Rcode:

hist(carprice$MPG.city,main="Histogram for MPG.city")

Solution3d:

To get the density plot execute below code:

Rcode:

ggplot(carprice, aes( x = Price)) + geom_density( )

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote