44
ภภภภ R ภภภภภภภภภ Computer Program in Education Research and Measurment ภภภภภภภ ภภภภภภภภภภภภภ

ภาษา R เบื้องต้น

Embed Size (px)

DESCRIPTION

ภาษา R เบื้องต้น. Computer Program in Education Research and Measurment ธวัชชัย เอี่ยมไพโรจน์. RGui. ออกจาก RGui. Help ใน R. help(print). การเปลี่ยนไดเรคทอรี. การเรียกไฟล์คำสั่งของ R มาทำงาน. exsample.R. # draw a smooth line through a scatter plot - PowerPoint PPT Presentation

Citation preview

Page 1: ภาษา  R  เบื้องต้น

ภาษา R เบื้��องต้�น

Computer Program in Education Research and Measurment

ธวั�ชช�ย เอ��ยมไพโรจน�

Page 2: ภาษา  R  เบื้องต้น

RGui

Page 3: ภาษา  R  เบื้องต้น

ออกจาก RGui

Page 4: ภาษา  R  เบื้องต้น

Help ใน R

Page 5: ภาษา  R  เบื้องต้น

help(print)

Page 6: ภาษา  R  เบื้องต้น

การเปลี่��ยนไดเรคทอร�

Page 7: ภาษา  R  เบื้องต้น

การเร�ยกไฟลี่�ค$าสั่��งของ R มาท$างาน

Page 8: ภาษา  R  เบื้องต้น

exsample.R

# draw a smooth line through a scatter plotplot(cars, main="Stopping Distance versus Speed")

lines(stats::lowess(cars))

Page 9: ภาษา  R  เบื้องต้น

การจ�ดการพ��นฐานก�บื้ numbers แลี่ะ vector

• x <- c(10.4, 5.6, 3.1, 6.4, 21.7)

หร�อ• assign(“x”, c(10.4, 5.6, 3.1, 6.4, 21.7)

Page 10: ภาษา  R  เบื้องต้น

x<- c(10.4, 5.6, 3.1, 6.4, 21.7)

Page 11: ภาษา  R  เบื้องต้น

print(x)

Page 12: ภาษา  R  เบื้องต้น

x=edit(x)

Page 13: ภาษา  R  เบื้องต้น

1/x

Page 14: ภาษา  R  เบื้องต้น

v<- 2*x + y + 1

Page 15: ภาษา  R  เบื้องต้น

log, exp, sin, cos, length ..etc.

Page 16: ภาษา  R  เบื้องต้น

paste()

Page 17: ภาษา  R  เบื้องต้น

?paste

Page 18: ภาษา  R  เบื้องต้น

Probability Distributions

Page 19: ภาษา  R  เบื้องต้น

help(Normal)

Page 20: ภาษา  R  เบื้องต้น

help(TDist)

Page 21: ภาษา  R  เบื้องต้น

help(Binomial)

Page 22: ภาษา  R  เบื้องต้น

Basic Plots

• Strip Charts

• Histograms

• Boxplots

• Scatter Plots

• Normal QQ Plots

Page 23: ภาษา  R  เบื้องต้น

help(stripchart)

Page 24: ภาษา  R  เบื้องต้น

stripchart(x) ; m <- mean(par("usr")[1:2])

Page 25: ภาษา  R  เบื้องต้น

help(hist)

Page 26: ภาษา  R  เบื้องต้น

hist(islands)

Page 27: ภาษา  R  เบื้องต้น

help(boxplot)

Page 28: ภาษา  R  เบื้องต้น

boxplot(count ~ spray, data = InsectSprays, col = "lightgray")

Page 29: ภาษา  R  เบื้องต้น

Scatter Plots

• plot()

• cor()

Page 30: ภาษา  R  เบื้องต้น

help(plot)

Page 31: ภาษา  R  เบื้องต้น

plot(cars)

Page 32: ภาษา  R  เบื้องต้น

help(cor)

Page 33: ภาษา  R  เบื้องต้น

cor(cbind(P = Cl[i], S = clS[i], K = clK[i]))

Page 34: ภาษา  R  เบื้องต้น

help(qqnorm)

Page 35: ภาษา  R  เบื้องต้น

qqnorm(precip, ylab = "Precipitation [in/yr] for 70 US cities")

Page 36: ภาษา  R  เบื้องต้น

Rcmdr

R Commander

Page 37: ภาษา  R  เบื้องต้น

Load Package Rcmdr

Page 38: ภาษา  R  เบื้องต้น

R Commander

Page 39: ภาษา  R  เบื้องต้น

Data Editor

Page 40: ภาษา  R  เบื้องต้น

Import from SPSS data set.

library(foreign, pos=4)

Dataset <- read.spss("C:/Documents and Settings/Administrator/Desktop/Data_SPSS/data6.sav", use.value.labels=TRUE, max.value.labels=Inf, to.data.frame=TRUE)

Page 41: ภาษา  R  เบื้องต้น

SPSS data set in R.

Page 42: ภาษา  R  เบื้องต้น

load("C:/Documents and Settings/Administrator/Desktop/Data_R/data11a2.RData")

Page 43: ภาษา  R  เบื้องต้น

Save : script & output file ?

Page 44: ภาษา  R  เบื้องต้น

Questions ?... Comments

http://www.kuisociety.net

http://www.r-burapha.com