demo/Chapter.1.2.R

# Section 1.2 R commands

# Section 1.2.2

library(LearnBayes)
data(studentdata)
studentdata[1,]
attach(studentdata)

# Section 1.2.3

table(Drink)
barplot(table(Drink),xlab="Drink",ylab="Count")

S=readline(prompt="Type  <Return>   to continue : ")

if (.Platform$OS.type == "unix") x11() else windows()

hours.of.sleep = WakeUp - ToSleep
summary(hours.of.sleep)
hist(hours.of.sleep,main="")

S=readline(prompt="Type  <Return>   to continue : ")

# Section 1.2.4

if (.Platform$OS.type == "unix") x11() else windows()

boxplot(hours.of.sleep~Gender,
  ylab="Hours of Sleep")

female.Haircut=Haircut[Gender=="female"]
male.Haircut=Haircut[Gender=="male"]
summary(female.Haircut)
summary(male.Haircut)

S=readline(prompt="Type  <Return>   to continue : ")

# Section 1.2.5

if (.Platform$OS.type == "unix") x11() else windows()

plot(jitter(ToSleep),jitter(hours.of.sleep))

fit=lm(hours.of.sleep~ToSleep)
fit
abline(fit)
bayesball/LearnBayes documentation built on May 11, 2019, 9:21 p.m.