funsRowColSums | R Documentation |
Two functions: row.sum
and col.sum
.
row.sum
returns the row sums of a given matrix
(in particular a contingency table) as a vector and
col.sum
returns the column sums of a given matrix as a vector.
row.sum
is equivalent to
rowSums
function and
col.sum
is equivalent to colSums
function in the base
package.
row.sum(ct)
col.sum(ct)
ct |
A matrix, in particular a contingency table |
row.sum
returns the row sums of ct
as a vector
col.sum
returns the column sums of ct
as a vector
Elvan Ceyhan
rowSums
and colSums
n<-20 #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:2,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)
row.sum(ct)
rowSums(ct)
col.sum(ct)
colSums(ct)
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-nnct(ipd,fcls)
row.sum(ct)
rowSums(ct)
col.sum(ct)
colSums(ct)
#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:4,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)
row.sum(ct)
rowSums(ct)
col.sum(ct)
colSums(ct)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.