mean(c(1, 2, NA ), na.rm=T)
x=1:9 y=sin(1:9) lm(y~x)$coefficients
x=1:9 y=sin(1:9) summary(lm(y~x))$r.squared
ここ参考に
x=seq(0,1,length=100) plot(x,sin(x),type="l")
par(xaxs="i", yaxs="i") x=seq(0,1,length=100) plot(x,sin(x),type="l")
plot(sin(1:9),pch=20)
pchの種類はここ参照
plot(sin(1:9),pch=20,cex=2)
par(mfrow = c(2, 3 ) ) par(mar=c(5,5,0.3,0.3)) //下左上右のmargin for(i in 1:6){plot(sin(1:9))}
library(gplots) redgreen(255) //マイクロアレイでみるやつ
plot(sin(1:9), xaxt="n") axis(side=1, at=c(0,3,5,8))
par(pty="s") plot(sin(1:9))
plot(sin(1:9),ann=F)
x=seq(0,1,len=100) plot(x,sin(x),xaxp=c(0, 0.5, 8))
0から0.5まで8等分する(目盛りは9個となる。)
as.numeric("5")
paste("ab","cd",sep="")
write.table(x,"x.txt",sep="\t")
ここ参照
data.delim()
x=c(0,1,2,3,4,5,6,7,8,9,10,11,12) y=x[intersect(which(x%%2==0),which(x%%3==0))] #AND z=x[union(which(x%%2==0),which(x%%3==0))] #OR
x <- c(3,2,5,1,4) y <- c(5,3,2,4,1) ox <- order(x) x <- x[ox] y <- y[ox]
x=c(1,2,3) rev(x)
choose(n,r)
x = c(1,2,3,4) fft(x)
でてくる値の横軸は周波数である。元の時系列が、a [s]ごとb+1回のサンプリングだったとすると、周波数領域の一目盛りはa*b [1/s]であり、周波数の最大値はb/2番目までのポイントである。
ここ参考にした。
f <- function(x) x^2 #一変数関数を作らないといけない。 integrate(f,0,1)
ただしf文を含む自作関数は先頭の関数しか有効でない??(うまくいっているような気もするが警告がでる)
f <- function(x) { if(x>0) return(x) else return(-x) } integrate(f,-1,0)
ここ参考に
x<-seq(0,1,by=0.1) y<-seq(0,1,by=0.1) f<-function(x,y){x^2+y^2} z<-outer(x,y,f) image(x,y,z)
outerがポイント