メモ

x<-seq(from=0.01,to=1,by=0.01)
y<-x
cx<-qchisq(1-x,1)
cy<-qchisq(1-y,1)
dx<-dchisq(cx,1)
dy<-dchisq(cy,1)
prodD<-outer(dx,dy,FUN="*")
sumC<-outer(cx,cy,FUN="+")
d2<-dchisq(sumC,2)
plot(prodD)
plot(sumC)
plot(d2)
行列の列の和をとる、行の和をとる、colSums(mat),rowSums(mat)

※FUNは大文字

  • 行列の行入れ替え、列入れ替え
> m<-matrix(1:12,3,4)
> m
     [,1] [,2] [,3] [,4]
[1,]    1    4    7   10
[2,]    2    5    8   11
[3,]    3    6    9   12
> m2<-m[c(1,3,2),c(1,2,3,4)]
> m2
     [,1] [,2] [,3] [,4]
[1,]    1    4    7   10
[2,]    3    6    9   12
[3,]    2    5    8   11
> m3<-m2[c(1,2,3),c(4,3,2,1)]
> m3
     [,1] [,2] [,3] [,4]
[1,]   10    7    4    1
[2,]   12    9    6    3
[3,]   11    8    5    2