MakeOTable
カテゴリ数がkでサンプル数がNのとき、個々のサンプルを1カラムと見立てた分割表は、表の要素が0か1かの表であり、列に関する和がすべて1であるような分割表である。
カテゴリ情報のベクトルとカテゴリのベクトルから、このような表を作る
MakeOTable(p,k)
MakeOTable<-function(p,k=c(0,1)){
n<-length(k)
m<-matrix(0,n,length(p))
for(i in 1:n){
m[i,which(p==k[i])]<-1
}
m
}
\name{MakeOTable}
\alias{MakeOTable}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
MakeOTable
}
\description{
カテゴリ数がkでサンプル数がNのとき、個々のサンプルを1カラムと見立てた分割表は、表の要素が0か1かの表であり、列に関する和がすべて1であるような分割表である。
カテゴリ情報のベクトルとカテゴリのベクトルから、このような表を作る
}
\usage{
MakeOTable(p,k)
}
\arguments{
\item{p}{サンプル数の長さのベクトル。要素はカテゴリ値}
\item{k}{カテゴリのベクトル}
}
%- maybe also 'usage' for other objects documented here.
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
行数がカテゴリ数、列数がサンプル数であるような行列
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
}
\examples{
Ns<-20
k<-c(0,1,3,"a")
p<-sample(k,Ns,replace=TRUE)
MakeOTable(p,k)