tab.vector: tab.vector

Usage Arguments Examples

View source: R/tab.vector.r

Usage

1
tab.vector(data = .data[1], sort = T)

Arguments

data
sort

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(data=.data[1],sort=T) {
    t1<-table(data)
    if (sort) {t1<-sort(t1,decreasing=T)}
    N<-margin.table(t1)
    t2<-data.frame(binconf(t1,N,include.x=T,include.n=T))
    t2[,c("PointEst","Lower","Upper")]<-round(t2[,c("PointEst","Lower","Upper")]*100,2)
    t2$ci<-paste("(",t2$Lower,"%,",t2$Upper,"%)",sep="")
    t2[,"PointEst"]<-paste(t2[,"PointEst"],"%",sep="")
    t2<-t2[,c("X","PointEst","ci")]
    t2["TOTAL",c("X","PointEst","ci")]<-c(N,"100%","")
    t2<-cbind(rownames(t2),t2)
    names(t2)<-c(label(data),"N","Percentage","95%CI")
    cat("*",label(data),"*\n",sep="")
    t2<-data.frame(t2,row.names=1)
    class(t2)<-c("z","data.frame")
    return(t2)
  }

gvdovandzung/thongke documentation built on May 23, 2020, 12:35 a.m.