Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you change this R script code a bit like variables name and etc but work same. rm(list=ls()) #install.packages(plyr) library(plyr) #load data file fuel_data =

can you change this R script code a bit like variables name and etc but work same.

rm(list=ls())

#install.packages("plyr")

library(plyr)

#load data file

fuel_data = read.csv("C:\\Users\\DELL\\Downloads\\data.csv")

#summary of data file

summary(fuel_data)

#visulaization of engine capacicity

x11()

hist(fuel_data$engine_capacity)

#visulaization of engine capacicity over time

engine_capacity_time = ts(data =fuel_data$engine_capacity, start = 2000,end = 2013)

ts.plot(engine_capacity_time, ylab = "engine_capacity")

#convert the fuel_type variable (string) into numeric

fuel = as.numeric(mapvalues(fuel_data$fuel_type, from = c("CNG","Diesel","Diesel Electric","Electricity","Electricity/Diesel","Electricity/Petrol","LPG","LPG / Petrol","Petrol","Petrol / E85", "Petrol / E85 (Flex Fuel)","Petrol Electric","Petrol Hybrid"), to = c(1,2,3,4,5,6,7,8,9,10,11,12,13)))

#visualization of fuel type

hist(fuel, xlab = "fuel type")

#visulaization of fuel type over time

fuel_time = ts(fuel,start=2000, end = 2013)

ts.plot(fuel_time)

#Is there is a relation between fuel type and engine capacicity?

#Hypothesis

#Ho: There is no relationship between fuel type and engine capacicity

#H1: There is a relationship between fuel type and engine capacicity

corr_test = cor.test(fuel, fuel_data$engine_capacity); corr_test

x11()

plot(fuel,fuel_data$engine_capacity)

#As the p-value is 2.2e-16. It means p-value is less than the level of significance which is 5%. So, at 5% level of significance H0 is rejected and conclude that there is a relationship between fuel type and engine capacicity

#convert the transmission (string) type into numeric

transmission = as.numeric(mapvalues(fuel_data$transmission_type, from = c("Automatic","Manual"), to = c(1,2)))

#index of missing values in transmission

missing = which(is.na(transmission))

#remove the missing values

omit_transmission = transmission[-missing]

#visualization of transmission type

hist(omit_transmission, xlab = "transmission type")

#Is different levels of transmission types have the same engine capacity?

#Ho: The cars with the different level of transmission types have the same engine capacity

#H1: The cars with the different level of transmission types have the different engine capacity

test1 = t.test(fuel_data$engine_capacity[-missing]~omit_transmission);test1

#As the p-value is 2.2e-16. It means p-value is less than the level of significance which is 5%. So, at 5% level of significance H0 is rejected and conclude that the cars with the different level of transmission types have the different engine capacity. AS the mean od automatic cars is 2498.039. It means the engine capacity of automatic cars is more than the manual cars.

#Is there a significant relationship between CO2 and CO emission?

#Ho: There is an insignificant relationship between CO2 and CO emission

#H1: There is a significant relationship between CO2 and CO emission

test2 = t.test(fuel_data$co2, fuel_data$co_emissions);test2

#As the p-value is 2.2e-16. It means p-value is less than the level of significance which is 5%. So, at 5% level of significance H0 is rejected and conclude that there is a significant relationship between CO2 and CO emission

#Visulaization of CO2 over time

CO2_time = ts(data = fuel_data$co2, start = 2000, end = 2013)

plot(CO2_time, ylab = "CO2")

##Visulaization of CO emission over time

CO_emission_time = ts(fuel_data$co_emissions, start = 2000, end = 2013)

plot(CO_emission_time, ylab = "CO emission")

#Is different fuel types have the same CO emission?

#Ho: The different fuel types have the same CO emission

#H1: Atleast one of the fuel type has not the same CO emission

test3 = aov(fuel~fuel_data$co_emissions);summary(test3)

#As the p-value is 2e-16. It means p-value is less than the level of significance which is 5%. So, at 5% level of significance H0 is rejected and conclude that atleast one of the fuel type has not the same CO emission

#Is there a significant relationship between fuel_cost_12000_miles and engine capacity?

#Ho: There is an insignificant relationship between fuel_cost_12000_miles and engine capacity

#H1: There is a significant relationship between fuel_cost_12000_miles and engine capacity

test4 = t.test(fuel_data$fuel_cost_12000_miles, fuel_data$engine_capacity);test4

#As the p-value is 2e-16. It means p-value is less than the level of significance which is 5%. So, at 5% level of significance H0 is rejected and conclude that there is a significant relationship between fuel_cost_12000_miles and engine capacity

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago