R语言学习/Introduction to R Programming

0.参考教材

R Cookbook: http://www.cookbook-r.com/

R in Action: http://www.amazon.com/R-Action-Robert-Kabacoff/dp/1935182390

ggplot2: Elegant Graphics for Data Analysis (Use R!): http://www.amazon.com/ggplot2-Elegant-Graphics-Data-Analysis/dp/0387981403

Advanced R: http://adv-r.had.co.nz/http://www.amazon.com/Advanced-Chapman-Hall-CRC-Series/dp/1466586966

1.安装软件

 

2.安装包

install.packages(‘ggplot2’)
library(ggplot2)
update.packages()

3.基本常识

v = c(1,4,4,3,2,2,3)
v[c(2,3,4)]
v[2:4]
v[c(2,4,3)]
v[-2]
v[-2:-4]
v[v<3]
which(v==3)

set.seed(250)
a = runif(3, min=0, max=100)
floor(a)
ceiling(a)
round(a,4)

data1=read.csv(file=”~/documents/rugby.txt”)
data2=read.table(file=”~/documents/rugby.txt”)
data3=read.csv(“http://www.macalester.edu/~kaplan/ISM/datasets/swim100m.csv”)
attach(data3)

set.seed(123)
x=rnorm(100,mean=100,sd=10)
set.seed(234)
y=rnorm(100,mean=100,sd=10)
hist(x,breaks=20)
plot(density(x))
plot(x)
boxplot(x,y)
boxplot(time~sex)
qqnorm(x)
qqline(x)
qqplot(x,y)

留下评论

电子邮件地址不会被公开。 必填项已用*标注