全サンプルを区別した分割表を作る

  • 予定パッケージ名
  • 関数名
    • MakeOTable
  • タイトル
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
}
  • Rdファイル
\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)