0% found this document useful (0 votes)
5 views

R Programming Lab Manual

R programming mandatory lab assignment

Uploaded by

prathishmanicks
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

R Programming Lab Manual

R programming mandatory lab assignment

Uploaded by

prathishmanicks
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

RATHINAM COLLEGE OF ARTS & SCIENCE

(AUTONOMOUS)
Coimbatore-641021
DEPARTMENT OF COMPUTER SCIENCE

18BCA6EP - Elective Practical - R Programming Lab Manual

Prepared by: Approved & Issued by: W.e.f Date:


Reviewed by:

Dr Karthikeyan S

In-charge HOD Principal


RATHINAM COLLEGE OF ARTS & SCIENCE (AUTONOMOUS)
Rathinam Techzone Campus, Pollachi Road, Eachanari,
Coimbatore - 641021, Tamil Nadu.
http://www.rathinamcollege.com

Department of Computer Science

Lab Manual for the Academic Year 2020-21

(in accordance with Computer Science syllabus)

SUBJECT : R Programming Lab

STREAM : BCA

Staff Incharge H.O.D


List of Lab Exercises

1. Introduction to R Defining and Downloading R and installing R


Programming
2. Write a simple R program to perform some Built-in mathematical
functions
3. Write a simple R program to perform vector operations
4. Write a simple R program to Reading data from csv files, inspection of
data.
5. Write a simple R program to Read data from Excel files
6. Write a simple R program to Working with datasets: Inspection, using
variables, attaching
7. Write a simple R program to Transformation of variables, subsets of
datasets and Merging datasets
8. Write a simple R program to perform Graphs
9. Write a simple R program to perform Regression
10.Write a simple R program to perform Analysis of variance (ANOVA)
1. Introduction to R Defining and Downloading R and installing R Programming
Installing R on a PC
Aim:
To Download R and installing R Programming
Procedure:
1. Go to http://ftp.heanet.ie/mirrors/cran.r-project.org.
2. Under “Download and Install R”, click on the “Windows” link.
3. Under “Subdirectories”, click on the “base” link.
4. On the next page, you should see a link saying something like “Download R 2.10.1 for
Windows” (or R X.X.X, where X.X.X gives the version of R, eg. R 2.11.1). Click on this link.
5. You may be asked if you want to save or run a file “R-2.10.1-win32.exe”. Choose “Save”
and save the file on the Desktop. Then double-click on the icon for the file to run it.
6. You will be asked what language to install it in - choose English.
7. The R Setup Wizard will appear in a window. Click “Next” at the bottom of the R Setup
wizard window.
8. The next page says “Information” at the top. Click “Next” again.
9. The next page says “Information” at the top. Click “Next” again.
10. The next page says “Select Destination Location” at the top. By default, it will suggest to
install R in “C:\Program Files” on your computer.
11. Click “Next” at the bottom of the R Setup wizard window.
12. The next page says “Select components” at the top. Click “Next” again.
13. The next page says “Startup options” at the top. Click “Next” again.
14. The next page says “Select start menu folder” at the top. Click “Next” again.
15. The next page says “Select additional tasks” at the top. Click “Next” again.
16. R should now be installed. This will take about a minute. When R has finished, you will
see “Completing the R for Windows Setup Wizard” appear. Click “Finish”.
17. To start R, you can either follow step 18, or 19:
18. Check if there is an “R” icon on the desktop of the computer that you are using. If so,
double-click on the “R” icon to start R. If you cannot find an “R” icon, try step 19 instead.
19. Click on the “Start” button at the bottom left of your computer screen, and then choose
“All programs”, and start R by selecting “R” (or R X.X.X, where X.X.X gives the version of
R, eg. R 2.10.0) from the menu of programs.
20. The R console (a rectangle) should pop up:
21. The R console (a rectangle) should pop up:

Install R on non-Windows computers (eg. Macintosh or Linux computers)


The instructions above are for installing R on a Windows PC. If you want to install R on a
computer that has a non-Windows operating system (for example, a Macintosh or
computer running Linux, you should download the appropriate R installer for that
operating system at http://ftp.heanet.ie/mirrors/cran.r-project.org and follow the R
installation instructions for the appropriate operating system
at http://ftp.heanet.ie/mirrors/cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-
installed_003f).
2. Write a simple R program to perform some Built-in mathematical functions
Aim:
To perform some Built-in mathematical functions

Procedure:

R provides the various mathematical functions to perform the mathematical calculation.


These mathematical functions are very helpful to find absolute value, square value and
much more calculations. In R, there are the following functions which are used:

S. No Function Description Example

1. abs(x) It returns the absolute value of x<- -4


input x. print(abs(x))
Output
[1] 4

2. sqrt(x) It returns the square root of x<- 4


input x. print(sqrt(x))
Output
[1] 2

3. ceiling(x) It returns the smallest integer x<- 4.5


which is larger than or equal to print(ceiling(x))
x. Output
[1] 5

4. floor(x) It returns the largest integer, x<- 2.5


which is smaller than or equal to print(floor(x))
x. Output
[1] 2

5. trunc(x) It returns the truncate value of x<- c(1.2,2.5,8.1)


input x. print(trunc(x))
Output
[1] 1 2 8

6. round(x, It returns round value of input x. x<- -4


digits=n) print(abs(x))
Output
4

7. cos(x), It returns cos(x), sin(x) value of x<- 4


sin(x), input x. print(cos(x))
tan(x) print(sin(x))
print(tan(x))
Output
[1] -06536436
[2] -0.7568025
[3] 1.157821

8. log(x) It returns natural logarithm of x<- 4


input x. print(log(x))
Output
[1] 1.386294

9. log10(x) It returns common logarithm of x<- 4


input x. print(log10(x))
Output
[1] 0.60206

10. exp(x) It returns exponent. x<- 4


print(exp(x))
Output
[1] 54.59815
3. Write a simple R program to perform vector operations
Aim:
To perform vector operations

Procedure:

# Create two vectors.


v1 <- c(3,8,4,5,0,11)
v2 <- c(4,11,0,8,1,2)

# Vector addition.
add.result <- v1+v2
print(add.result)

# Vector subtraction.
sub.result <- v1-v2
print(sub.result)

# Vector multiplication.
multi.result <- v1*v2
print(multi.result)

# Vector division.
divi.result <- v1/v2
print(divi.result)

v <- c(3,8,4,5,0,11, -9, 304)

# Sort the elements of the vector.


sort.result <- sort(v)
print(sort.result)

# Sort the elements in the reverse order.


revsort.result <- sort(v, decreasing = TRUE)
print(revsort.result)

# Sorting character vectors.


v <- c("Red","Blue","yellow","violet")
sort.result <- sort(v)
print(sort.result)

# Sorting character vectors in reverse order.


revsort.result <- sort(v, decreasing = TRUE)
print(revsort.result)
4. Write a simple R program to Reading data from csv files, inspection of data.

Aim
To Perform R program to Reading data from csv files, inspection of data

Procedure:
Input as CSV File
The csv file is a text file in which the values in the columns are separated by a comma. Let's
consider the following data present in the file named input.csv.
You can create this file using windows notepad by copying and pasting this data. Save the file
as input.csv using the save As All files(*.*) option in notepad.
id,name,salary,start_date,dept
1,Rick,623.3,2012-01-01,IT
2,Dan,515.2,2013-09-23,Operations
3,Michelle,611,2014-11-15,IT
4,Ryan,729,2014-05-11,HR
5,Gary,843.25,2015-03-27,Finance
6,Nina,578,2013-05-21,IT
7,Simon,632.8,2013-07-30,Operations
8,Guru,722.5,2014-06-17,Finance
Reading a CSV File
Following is a simple example of read.csv() function to read a CSV file available in your
current working directory −
data <- read.csv("input.csv")
print(data)
When we execute the above code, it produces the following result −
id, name, salary, start_date, dept
1 1 Rick 623.30 2012-01-01 IT
2 2 Dan 515.20 2013-09-23 Operations
3 3 Michelle 611.00 2014-11-15 IT
4 4 Ryan 729.00 2014-05-11 HR
5 NA Gary 843.25 2015-03-27 Finance
6 6 Nina 578.00 2013-05-21 IT
7 7 Simon 632.80 2013-07-30 Operations
8 8 Guru 722.50 2014-06-17 Finance
Analyzing the CSV File
By default the read.csv() function gives the output as a data frame. This can be easily checked
as follows. Also we can check the number of columns and rows.
data <- read.csv("input.csv")

print(is.data.frame(data))
print(ncol(data))
print(nrow(data))
When we execute the above code, it produces the following result −
[1] TRUE
[1] 5
[1] 8
Once we read data in a data frame, we can apply all the functions applicable to data frames as
explained in subsequent section.
Get the maximum salary
# Create a data frame.
data <- read.csv("input.csv")

# Get the max salary from data frame.


sal <- max(data$salary)
print(sal)
When we execute the above code, it produces the following result −
[1] 843.25
Get the details of the person with max salary
We can fetch rows meeting specific filter criteria similar to a SQL where clause.
# Create a data frame.
data <- read.csv("input.csv")

# Get the max salary from data frame.


sal <- max(data$salary)

# Get the person detail having max salary.


retval <- subset(data, salary == max(salary))
print(retval)
When we execute the above code, it produces the following result −
id name salary start_date dept
5 NA Gary 843.25 2015-03-27 Finance
Get all the people working in IT department
# Create a data frame.
data <- read.csv("input.csv")

retval <- subset( data, dept == "IT")


print(retval)
When we execute the above code, it produces the following result −
id name salary start_date dept
1 1 Rick 623.3 2012-01-01 IT
3 3 Michelle 611.0 2014-11-15 IT
6 6 Nina 578.0 2013-05-21 IT
5. Write a simple R program to Read data from Excel files
Aim:
To Perform R program to Read data from Excel files
Procedure:
Install xlsx Package
You can use the following command in the R console to install the "xlsx" package. It may ask to
install some additional packages on which this package is dependent. Follow the same
command with required package name to install the additional packages.
install.packages("xlsx")
Verify and Load the "xlsx" Package
Use the following command to verify and load the "xlsx" package.
# Verify the package is installed.
any(grepl("xlsx",installed.packages()))

# Load the library into R workspace.


library("xlsx")
When the script is run we get the following output.
[1] TRUE
Loading required package: rJava
Loading required package: methods
Loading required package: xlsxjars
Input as xlsx File
Open Microsoft excel. Copy and paste the following data in the work sheet named as sheet1.
id name salary start_date dept
1 Rick 623.3 1/1/2012 IT
2 Dan 515.2 9/23/2013 Operations
3 Michelle 611 11/15/2014 IT
4 Ryan 729 5/11/2014 HR
5 Gary 43.25 3/27/2015 Finance
6 Nina 578 5/21/2013 IT
7 Simon 632.8 7/30/2013 Operations
8 Guru 722.5 6/17/2014 Finance
Also copy and paste the following data to another worksheet and rename this worksheet to
"city".
name city
Rick Seattle
Dan Tampa
Michelle Chicago
Ryan Seattle
Gary Houston
Nina Boston
Simon Mumbai
Guru Dallas
Save the Excel file as "input.xlsx". You should save it in the current working directory of the R
workspace.
Reading the Excel File
The input.xlsx is read by using the read.xlsx() function as shown below. The result is stored as
a data frame in the R environment.
# Read the first worksheet in the file input.xlsx.
data <- read.xlsx("input.xlsx", sheetIndex = 1)
print(data)
When we execute the above code, it produces the following result −
id, name, salary, start_date, dept
1 1 Rick 623.30 2012-01-01 IT
2 2 Dan 515.20 2013-09-23 Operations
3 3 Michelle 611.00 2014-11-15 IT
4 4 Ryan 729.00 2014-05-11 HR
5 NA Gary 843.25 2015-03-27 Finance
6 6 Nina 578.00 2013-05-21 IT
7 7 Simon 632.80 2013-07-30 Operations
7 8 Guru 722.50 2014-06-17 Finance
6. Write a simple R program to Working with datasets: Inspection, using
variables, attaching
Aim:
To Perform R program to Working with datasets: Inspection, using
variables, attaching
Procedure:
Creating datasets
Let’s start by learning how to create a dataset in R. This turns out to be very simple — just
combine vectors using the data.frame() command.
# Create three vectors
name <- c("al", "bea", "carol")
age <- c(6, 7, 4)
hair <- c("brown", "green", "blond")

# Create data frame


children <- data.frame(name, age, hair)
children
name age hair
1 al 6 brown
2 bea 7 green
3 carol 4 blond
# Creating a data frame can also be done without first saving vectors
children <- data.frame(
name = c("al", "bea", "carol"),
age = c(6, 7, 4),
hair = c("brown", "green", "blond")
)
children
name age hair
1 al 6 brown
2 bea 7 green
3 carol 4 blond
We created a dataset called children, which has 3 rows and 3 columns. We used two
approaches that differ in whether they first save vectors to R’s memory.
Dataset structure
More important than learning the mechanics of creating a dataset in R is to understand their
general structure:
1. Each column should consist of a vector that gives some fact about the world (e.g., age in
years). We usually refer to these columns as variables.
2. At least one column should identify who or what the information in the data is about.
Such a variable is called an “id” variable or “key”. In the children dataset above this
variable is name. The remaining variables have the facts or measurements that we care
about. For example, we gather from the dataset that Al is 6 years old (one fact) and that
Al has brown hair (a second fact).
To better understand the proper structure of datasets, let’s create a second data frame.
Suppose here that gdp_pc is a measure of a country’s GDP per capita in a given year.
(Use ?expand.grid and ?runif to learn more about these functions, though that is not a priority
right now.)
countries <- data.frame(
expand.grid(country = c("USA", "China", "Sudan"), year = 1994:1996),
gdp_pc = round(runif(9, 1000, 20000), 0)
)
countries
country year gdp_pc
1 USA 1994 16454
2 China 1994 13753
3 Sudan 1994 16899
4 USA 1995 16964
5 China 1995 2358
6 Sudan 1995 4262
7 USA 1996 5995
8 China 1996 8699
9 Sudan 1996 3242
Basic commands
Here are some commands that are useful for getting to know your data and for understanding
dataset structures in general.
Dimensions
The first is dim(), which gives the dimensions of a data frame. The number of rows are listed
first, columns second.
dim(countries)
[1] 9 3
Use nrow() and ncol() to to get the number of rows or columns separately. These commands
are useful for code generalization.
nrow(countries)
[1] 9
ncol(countries)
[1] 3
Snapshots
Use head() and tail() to look at the first and last few rows of a dataset, respectively. This is
more useful when we have datasets with many observations.
head(countries)
country year gdp_pc
1 USA 1994 16454
2 China 1994 13753
3 Sudan 1994 16899
4 USA 1995 16964
5 China 1995 2358
6 Sudan 1995 4262
tail(countries)
country year gdp_pc
4 USA 1995 16964
5 China 1995 2358
6 Sudan 1995 4262
7 USA 1996 5995
8 China 1996 8699
9 Sudan 1996 3242
Other useful commands to get to know variables better include summary(), table(),
and prop.table().
# Get some summary information about each variable
summary(countries)
country year gdp_pc
USA :3 Min. :1994 Min. : 2358
China:3 1st Qu.:1994 1st Qu.: 4262
Sudan:3 Median :1995 Median : 8699
Mean :1995 Mean : 9847
3rd Qu.:1996 3rd Qu.:16454
Max. :1996 Max. :16964
# Number of observations by country
table(countries$country)

USA China Sudan


3 3 3
# Proportion of observations by country
prop.table(table(countries$country))

USA China Sudan


0.3333333 0.3333333 0.3333333

7. Write a simple R program to Transformation of variables, subsets of datasets


and Merging datasets
Aim:
To perform R program to Transformation of variables, subsets of datasets
and Merging datasets
8. Write a simple R program to perform Graphs
Aim:
To perform R Program Graphs
Procedure:
Bar Plots of Counts

1 barplot( c(40, 60) )

1 plot( as.factor(q4) )
2 barplot( table(q4) )

1 barplot( as.matrix( table(workshop) ), beside = FALSE)

1 plot(workshop, gender, xlab = "", ylab = "")

1 mosaicplot( table(workshop, gender), main = "" )

Bar Plots of Means

1 myMeans <- tapply(q1, gender, mean, na.rm = TRUE)


2 barplot(myMeans)

Adding Titles, Labels, Colors, and Legends


barplot( table(gender,workshop),
beside = TRUE,
col = c("gray90", "gray60"),
xlab = "Workshop",
ylab = "Count",
main = "Number of males and females \nin each workshop")
legend( "topright",
legend = c("Female", "Male"),
fill = c("gray90", "gray60") )
Graphics Parameters and Multiple Plots on a Page
par(mfrow = c(2,2)) # 2 rows, 2 columns
barplot( table(gender, workshop) )
barplot( table(workshop, gender) )
barplot( table(gender, workshop), beside = TRUE )
barplot( table(workshop, gender), beside = TRUE )
par(mfrow = c(1, 1)) # 1 row, 1 column (back to the default)
Pie Charts

1 pie( table(workshop),
2 col = c("white", "gray90", "gray60", "black") )

Histograms
hist(posttest, breaks = 20, probability = TRUE)
lines( density(posttest) )
rug(posttest)
Normal QQ Plots
library("car")
qq.plot(posttest,
labels = row.names(mydata100),
col = "black")
Scatter Plots and Line Plots

1 par( mfrow=c(2,2) ) # 2 rows, 2 columns.


2
3 plot( pretest, posttest, type = "p", main = 'type = "p")
4 plot( pretest, posttest, type = "l", main = 'type = "l")
5 plot( pretest, posttest, type = "b", main = 'type = "b")
6 plot( pretest, posttest, type = "h", main = 'type = "h")
7
8 par( mfrow=c(1,1) ) # Back to 1 row, 1 column.
9. Write a simple R program to perform Regression
Aim
To perform Regression in R Programming
Procedure

Steps to Establish a Regression


A simple example of regression is predicting weight of a person when his height is known. To
do this we need to have the relationship between height and weight of a person.
The steps to create the relationship is −
 Carry out the experiment of gathering a sample of observed values of height and
corresponding weight.
 Create a relationship model using the lm() functions in R.
 Find the coefficients from the model created and create the mathematical equation
using these
 Get a summary of the relationship model to know the average error in prediction. Also
called residuals.
 To predict the weight of new persons, use the predict() function in R.

Input Data
Below is the sample data representing the observations −
# Values of height
151, 174, 138, 186, 128, 136, 179, 163, 152, 131

# Values of weight.
63, 81, 56, 91, 47, 57, 76, 72, 62, 48

lm() Function
This function creates the relationship model between the predictor and the response
variable.

Syntax
The basic syntax for lm() function in linear regression is −
lm(formula,data)
Following is the description of the parameters used −
 formula is a symbol presenting the relation between x and y.
 data is the vector on which the formula will be applied.
Create Relationship Model & get the Coefficients
x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)

# Apply the lm() function.


relation <- lm(y~x)

print(relation)
When we execute the above code, it produces the following result −
Call:
lm(formula = y ~ x)

Coefficients:
(Intercept) x
-38.4551 0.6746

Get the Summary of the Relationship


x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)

# Apply the lm() function.


relation <- lm(y~x)

print(summary(relation))
When we execute the above code, it produces the following result −
Call:
lm(formula = y ~ x)

Residuals:
Min 1Q Median 3Q Max
-6.3002 -1.6629 0.0412 1.8944 3.9775

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -38.45509 8.04901 -4.778 0.00139 **
x 0.67461 0.05191 12.997 1.16e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.253 on 8 degrees of freedom


Multiple R-squared: 0.9548, Adjusted R-squared: 0.9491
F-statistic: 168.9 on 1 and 8 DF, p-value: 1.164e-06
predict() Function

Syntax
The basic syntax for predict() in linear regression is −
predict(object, newdata)
Following is the description of the parameters used −
 object is the formula which is already created using the lm() function.
 newdata is the vector containing the new value for predictor variable.

Predict the weight of new persons


# The predictor vector.
x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)

# The resposne vector.


y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)

# Apply the lm() function.


relation <- lm(y~x)

# Find weight of a person with height 170.


a <- data.frame(x = 170)
result <- predict(relation,a)
print(result)
When we execute the above code, it produces the following result −
1
76.22869

Visualize the Regression Graphically


# Create the predictor and response variable.
x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)
relation <- lm(y~x)

# Give the chart file a name.


png(file = "linearregression.png")

# Plot the chart.


plot(y,x,col = "blue",main = "Height & Weight Regression",
abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Weight in Kg",ylab = "Height in cm")

# Save the file.


dev.off()
When we execute the above code, it produces the following result −
10. Write a simple R program to perform Analysis of variance (ANCOVA)
Aim
To Perform Analysis of Covariance (ANCOVA)
Procedure
Input Data
Create a data frame containing the fields "mpg", "hp" and "am" from the data set mtcars. Here
we take "mpg" as the response variable, "hp" as the predictor variable and "am" as the
categorical variable.
input <- mtcars[,c("am","mpg","hp")]
print(head(input))
When we execute the above code, it produces the following result −
am mpg hp
Mazda RX4 1 21.0 110
Mazda RX4 Wag 1 21.0 110
Datsun 710 1 22.8 93
Hornet 4 Drive 0 21.4 110
Hornet Sportabout 0 18.7 175
Valiant 0 18.1 105
ANCOVA Analysis
We create a regression model taking "hp" as the predictor variable and "mpg" as the
response variable taking into account the interaction between "am" and "hp".
Model with interaction between categorical variable and predictor variable
# Get the dataset.
input <- mtcars

# Create the regression model.


result <- aov(mpg~hp*am,data = input)
print(summary(result))
When we execute the above code, it produces the following result −
Df Sum Sq Mean Sq F value Pr(>F)
hp 1 678.4 678.4 77.391 1.50e-09 ***
am 1 202.2 202.2 23.072 4.75e-05 ***
hp:am 1 0.0 0.0 0.001 0.981
Residuals 28 245.4 8.8
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This result shows that both horse power and transmission type has significant effect on miles
per gallon as the p value in both cases is less than 0.05. But the interaction between these
two variables is not significant as the p-value is more than 0.05.
Model without interaction between categorical variable and predictor variable
# Get the dataset.
input <- mtcars

# Create the regression model.


result <- aov(mpg~hp+am,data = input)
print(summary(result))
When we execute the above code, it produces the following result −
Df Sum Sq Mean Sq F value Pr(>F)
hp 1 678.4 678.4 80.15 7.63e-10 ***
am 1 202.2 202.2 23.89 3.46e-05 ***
Residuals 29 245.4 8.5
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This result shows that both horse power and transmission type has significant effect on miles
per gallon as the p value in both cases is less than 0.05.
Comparing Two Models
Now we can compare the two models to conclude if the interaction of the variables is truly
in-significant. For this we use the anova() function.

# Get the dataset.


input <- mtcars

# Create the regression models.


result1 <- aov(mpg~hp*am,data = input)
result2 <- aov(mpg~hp+am,data = input)

# Compare the two models.


print(anova(result1,result2))
When we execute the above code, it produces the following result −
Model 1: mpg ~ hp * am
Model 2: mpg ~ hp + am
Res.Df RSS Df Sum of Sq F Pr(>F)
1 28 245.43
2 29 245.44 -1 -0.0052515 6e-04 0.9806
As the p-value is greater than 0.05 we conclude that the interaction between horse power
and transmission type is not significant. So the mileage per gallon will depend in a similar
manner on the horse power of the car in both auto and manual transmission mode.

You might also like