Reference no: EM133803700
Assignment: Programming for Business Analytics
We will use built-in datasets from R.
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
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.
1. Find cars with housepower(hp) greater than 120, and weight(wt) greater than 3.5
2. Create summary statistics for the "hp" column for cars with displacement(disp) greater than 110.
3. Find the mean of the variable mpg where cars with cylinders(cyl) > 4
4. Find the car which has highest displacement (disp)
5. 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)
6. create a line graph that displays the relationship between the variables 'mpg' (miles per gallon) and 'disp' (displacement) (hint: x=disp, y=mpg)
7. create a boxplot that visualizes the distribution of hp (horsepower) for each number of cylinders (cyl) in the mtcars dataset.
8. Display the count of cars that are automatic (am == 0) Hint: is the count equal to the number of rows or columns?