1 | tab1n(.data, selectrow = 0)
|
.data |
|
selectrow |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##---- 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, selectrow = 0)
{
if (is.null(ncol(.data))) {
t1 <- table(.data)
N <- length(.data)
t2 <- data.frame(binconf(t1, N, include.x = T, include.n = T))
row.names(t2) <- paste(label(.data), row.names(t2), sep = ":")
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", "N", "PointEst", "ci")]
t2 <- cbind(rownames(t2), t2)
names(t2) <- c("Variables", "X", "N", "Percentage", "95%CI")
t2 <- (data.frame(t2, row.names = 1))
if (nrow(t2) == 2 & selectrow != 0)
t2 <- t2[selectrow, ]
class(t2) <- c("z", "data.frame")
return(t2)
}
else {
t2 <- rbind(tab1n(.data[, 1], selectrow = selectrow),
tab1n(.data[, -1], selectrow = selectrow))
class(t2) <- c("z", "data.frame")
return(t2)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.