ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

Rstudio

 

Download and go through Week2Part2 video and follow the process I have to demo your dataset. Start from Week2_Part2.R script, change it according to your selected datset from Quiz2. Then submit to this link:

1. Your modified script.

2. A screenshot report showing the outputs from your rstudio after executing all activities.

Week2_Part2.R script:

  

setwd(“C:/Users/ialsmadi/Desktop/University_of_Cumberlands/Lectures/Week2/RScripts”)

getwd()

# Import test data

data<-read.csv(“yearly_sales.csv”)

#A 5-number summary is a set of 5 descriptive statistics for summarizing a continuous univariate data set. 

#It consists of the data set’s: minimum, 1st quartile, median, 3rd quartile, maximum

#Find the set, L, of data below the median. The 1st quartile is the median of L.

#Find the set, U, of data above the median. The 3rd quartile is the median of U.

print(summary(data))

anscombe<-read.csv(“anscombe.csv”)

print(summary(anscombe))

sd(anscombe$X)

var(anscombe$X)

sd(anscombe$x1)

var(anscombe$x1)

sd(anscombe$x2)

var(anscombe$x2)

sd(anscombe$x3)

var(anscombe$x3)

sd(anscombe$x4)

var(anscombe$x4)

sd(anscombe$y1)

var(anscombe$y1)

sd(anscombe$y2)

var(anscombe$y2)

sd(anscombe$y3)

var(anscombe$y3)

##– now some “magic” to do the 4 regressions in a loop:

ff <- y ~ x

mods <- setNames(as.list(1:4), paste0(“lm”, 1:4))

for(i in 1:4) {

ff[2:3] <- lapply(paste0(c(“y”,”x”), i), as.name)

## or ff[[2]] <- as.name(paste0(“y”, i))

## ff[[3]] <- as.name(paste0(“x”, i))

mods[[i]] <- lmi <- lm(ff, data = anscombe)

print(anova(lmi))

}

## See how close they are (numerically!)

sapply(mods, coef)

lapply(mods, function(fm) coef(summary(fm)))

## Now, do what you should have done in the first place: PLOTS

op <- par(mfrow = c(2, 2), mar = 0.1+c(4,4,1,1), oma = c(0, 0, 2, 0))

for(i in 1:4) {

ff[2:3] <- lapply(paste0(c(“y”,”x”), i), as.name)

plot(ff, data = anscombe, col = “red”, pch = 21, bg = “orange”, cex = 1.2,

xlim = c(3, 19), ylim = c(3, 13))

abline(mods[[i]], col = “blue”)

}

mtext(“Anscombe’s 4 Regression data sets”, outer = TRUE, cex = 1.5)

par(op)

plot(sort(data$num_of_orders))

hist(sort(data$num_of_orders))

plot(density(sort(data$num_of_orders)))

plot(sort(data$gender))

hist(sort(data$sales_total))

plot(density(sort(data$sales_total)))

library(lattice)

densityplot(data$num_of_orders)

# top plot

# bottom plot as log10 is actually

# easier to read, but this plot is in natural log

densityplot(log(data$num_of_orders))

densityplot(data$sales_total)

densityplot(log(data$sales_total))

hist(data$sales_total, breaks=100, main=”Sales total”,

 xlab=”sales”, col=”gray”)

# draw a line for the media

abline(v = median(data$sales_total), col = “magenta”, lwd = 4)

# use rug() function to see the actual datapoints

rug(data$sales_total)

#Boxplots can be created for individual variables or for variables by group. 

#The format is boxplot(x, data=), where x is a formula and data= denotes the data frame providing 

#the data.

boxplot(data$sales_total,data=data, main=”Dis by Sales”, 

xlab=”Sales”, ylab=”Total”)

# Boxplot of MPG by Car Cylinders, using one of R built-in datasets 

boxplot(mpg~cyl,data=mtcars, main=”Car Milage Data”, 

xlab=”Number of Cylinders”, ylab=”Miles Per Gallon”)

#in our boxplot above, we might want to draw a horizontal line at 12 where the national standard is.

abline(h = 12)

boxplot(data$sales_total,data=data, main=”Total sales Bplot”, 

xlab=”Sales”, ylab=”Total”)

# Dot chart of a single numeric vector

dotchart(mtcars$mpg, labels = row.names(mtcars),

cex = 0.6, xlab = “mpg”)

#install.packages(“ROCR”)

#library(ROCR)

# Simple Scatterplot

attach(mtcars)

plot(wt, mpg, main=”Scatterplot Example”, 

xlab=”Car Weight “, ylab=”Miles Per Gallon “, pch=19)

#The R function abline() can be used to add vertical, horizontal or regression lines to a graph

plot(data$sales_total, data$gender)

# Add fit lines

abline(lm(data$sales_total~ data$num_of_orders), col=”red”) # regression line (y~x) 

lines(lowess(data$sales_total, data$num_of_orders), col=”blue”) # lowess line (x,y)

# Basic Scatterplot Matrix

pairs(data)

pairs(data[0:2])

# Scatterplot Matrices from the car Package

install.packages(“car”)

library(car)

install.packages(“ggplot2”)

library(ggplot2)

quit()

  • 2 years ago
  • 15
ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!