R メモ
サンプル
複素数
> plot(c(-4,4), c(-4,4), type="n")
> z <- complex(12, , , 2, 1:12*(pi/6))
> points(z)
正規分布 (平均 0, 分散 1)
> x <- seq(-4, 4, 0.1)
> curve(dnorm(x, 0, 1), from=-4, to=4, lwd=3, col="blue", main="正規分布 (平均 0, 分散 1)")
サイコロ
> dice <- function(x){floor(runif(x, 1, 7))}
> d <- dice(100)
> hist(d, breaks=0:6, col="gray")
データ
boolean
ベクトル
> x<-c(3, 2, 5, 7, 4, 2.5, 10)
> assign("y", 1:7)
> names(x)<-y
> x
1 2 3 4 5 6 7
3.0 2.0 5.0 7.0 4.0 2.5 10.0
行列
> matrix(0, 2, 3)
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
配列
> array(1:12, c(2, 3, 2))
, , 1
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
, , 2
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
リスト
演算子
+ - * / ^ %/% %%
%*%
= <- ->
> < >= <= == !=
! & | && || xor
制御
- for in
- function
- if else
- repeat
- while
コメントアウト
組み込み関数
- abline
- abs
- acos
- aov
- apply
- array
- as.data_type
- asin
- assign
- atan
- attach
- axis
- barplot
- boxplot
- c
- cbind
- character
- choose
- class
- colnames
- colnames
- colors
- complex
- coplot
- cos
- data.entry
- data.frame
- data
- dbeta
- dbinom
- dcauchy
- dchisq
- density
- dexp
- df
- dgamma
- dgeom
- dhyper
- dim
- dlnorm
- dlogis
- dmultinom
- dnorm
- dpois
- dt
- dunif
- dweibull
- edit.data.frame
- edit
- eigen
- exp
- fix
- integer
- IQR
- is.data_type
- legend
- length
- lines
- list
- log10
- log
- logical
- ls
- matplot
- matrix
- max
- mean
- median
- min
- mode
- mosaicplot
- names
- ncol
- noquote
- nrow
- null
- numerical
- order
- pairs
- par
- pbeta
- pbinum
- pcauchy
- pchisq
- pexp
- pf
- pgamma
- pgeom
- phyper
- pie
- plnorm
- plogis
- plot
- pnbinom
- pnorm
- ppois
- pt
- punif
- pweibull
- qbeta
- qbinum
- qcauchy
- qchisq
- qexp
- qf
- qgamma
- qgeom
- qhyper
- qlnorm
- qlogis
- qnbinom
- qnorm
- qpois
- qt
- quantile
- qweibull
- range
- ransort.list
- rbind
- read.table
- rev
- rm
- rnorm
- round
- rownames
- rownames
- runif
- scan
- sd
- seq
- sin
- sink
- solve
- sort
- sqrt
- stars
- sum
- summary
- symbols
- t
- table
- tan
- text
- title
- var
- vector
- write
リンク
ツール