BZAN4397 PROGRAMMING FOR BUS ANALYTICS

Description

We will use built-in datasets from R.

Don't use plagiarized sources. Get Your Custom Assignment on
BZAN4397 PROGRAMMING FOR BUS ANALYTICS
From as Little as $13/Page

1. dataset mtcars

Here’s a brief overview of the variables included in the mtcars dataset:

mpg: Miles/(US) gallon
cyl: Number of cylinders
disp: Displacement (cubic inches)
hp: Gross horsepower
drat: Rear axle ratio
wt: Weight (1000 lbs)
qsec: 1/4 mile time
vs: V/S (V-engine or straight engine; here, it’s a binary indicator, with ‘0’ indicating a V-engine and ‘1’ indicating a straight engine)
am: Transmission (0 = automatic, 1 = manual)
gear: Number of forward gears
carb: Number of carburetors

Please create a new R script and paste the following script into R.

##—–This is the instruction————-

#load dataset mtcars
data(mtcars)

#display the structure and head of the dataset
str(mtcars)
head(mtcars)

#choose 5 questions to answer from the questions below, please copy and paste the questions you choose into your r script. If you answer all the questions, Only the first 5 answers will be graded. Save your file frequently and submit it after completion.

#a. Find cars with housepower(hp) greater than 120, and weight(wt) greater than 3.5

#b. Create summary statistics for the “hp” column for cars with displacement(disp) greater than 110.

#c. Find the mean of the variable mpg where cars with cylinders(cyl) > 4

#d. Find the car which has highest displacement (disp)

# e. create a scatter plot using ggplot2 to visualize the relationship between a car’s weight (wt) and its miles per gallon (mpg) (hint: x=wt, y=mpg)

# f. create a line graph that displays the relationship between the variables ‘mpg’ (miles per gallon) and ‘disp’ (displacement) (hint: x=disp, y=mpg)

# g. create a boxplot that visualizes the distribution of hp (horsepower) for each number of cylinders (cyl) in the mtcars dataset.

#h. Display the count of cars that are automatic (am == 0) Hint: is the count equal to the number of rows or columns?