Professional Documents
Culture Documents
Tut 2
Tut 2
getwd()
setwd("C:/bes/lab 2")
data1 <- read.table("mtcars.csv",header=TRUE,sep=",",quote="\"",
stringsAsFactors = FALSE)
data1$am <- factor(data1$am,ordered=FALSE,levels=c(0,1),labels =
c("automatic","manual"))
data2 <- read.table("mtcars.csv",header=TRUE, sep=",",quote="\"",
stringsAsFactors=TRUE)
am.table <- table(data1$am)
prop.table(am.table)
prop.table(am.table)*100
#Exercise 2:
data1$gear <- factor(data1$gear,ordered=TRUE,levels=c(3,4,5),labels =
c("3gears","4gears","5gears"))
gearVSam.table2 <- table(data1$am,data1$gear)
gearVSam.table2
#Boxplot
boxplot(data1$mpg)
boxplot.stats(data1$mpg)
boxplot(data1$mpg ~ data1$gear)
#Excercise5
Data4 <- read.table("PriceChange",header=TRUE,sep=",",quote="\"",
stringsAsFactors = FALSE)
Extracted5<- data1[1:3,]
Summary(data4[c(“Jan”, “Apr”)])
t.test (data4$Jan, data4$Apr, paired=TRUE, alternative=”two.sided”,
conf.level=0.90)
Reject Ho if p-value = 0.06 < alpha = 0.1 Reject Ho and we have enough evidence that
the recession was affecting the stock market.