Nguyen Tan Dat
5/12/2017
R provides a wide variety of statistical (linear and nonlinear modelling, time-series analysis, classification, clustering etc) and graphical techniques, and is highly extensible.
The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.
Book “The Art of R Programming” http://diytranscriptomics.com/Reading/files/The%20Art%20of%20R%20Programming.pdf
Write in Console Studio
install.packages("swirl")
library("swirl")
# Follow as instructed.
#Facet grid
sp <- ggplot(tips, aes(x=total_bill, y=tip/total_bill))
sp + geom_point(shape =1)
sp + facet_grid(sex ~ day)+ geom_point(shape =1)
par(mfrow=c(2,4))
days <- c("Thur", "Fri", "Sat", "Sun")
sexes <- unique(tips$sex)
for (i in 1:length(sexes)) {
for (j in 1:length(days)) {
currdata <- tips[tips$day == days[j] & tips$sex == sexes[i],]
plot(currdata$total_bill, currdata$tip/currdata$total_bill,
main=paste(days[j], sexes[i], sep=", "), ylim=c(0,0.7), las=1)
}
}
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1