Displaying 3 results from an estimated 3 matches for "numlevels".
2011 Aug 25
2
within-groups variance and between-groups variance
...Within-Groups Variance:
=======================
calcWithinGroupsVariance <- function(variable,groupvariable)
{
# find out how many values the group variable can take
groupvariable2 <- as.factor(groupvariable[[1]])
levels <- levels(groupvariable2)
numlevels <- length(levels)
# get the mean and standard deviation for each group:
numtotal <- 0
denomtotal <- 0
for (i in 1:numlevels)
{
leveli <- levels[i]
levelidata <- variable[groupvariable==leveli,]
levelilen...
2012 Mar 20
1
overriding "summary.default" or "summary.data.frame". How?
...na.rm=TRUE))
sumdat <- rbind(sumdat, sd= apply(datn, 2, sd, na.rm=TRUE))
sumdat <- rbind(sumdat, var= apply(datn, 2, var, na.rm=TRUE))
sumdat <- rbind(sumdat, "NA's"=apply(datn, 2, function(x) sum(is.na(x))))
signif(sumdat, digits)
}
summary.factor <- function(y, numLevels) {
## 5 nested functions to be used later
divr <- function(p=0){
ifelse ( p>0 & p < 1, -p * log2(p), 0)
}
entropy <- function(p){
sum ( divr(p) )
}
maximumEntropy <- function(N) -log2(1/N)
normedEntropy <- function(x) entropy(x)/ maximumEntropy(length(x)...
2010 Mar 30
1
Adding RcppFrame to RcppResultSet causes segmentation fault
...// Third column will be a factor. In the current implementation the
// level names are copied to every factor value (and factors
// in the same column must have the same level names). The level names
// for a particular column will be factored out (pardon the pun) in
// a future release.
int numLevels = 2;
std::string *levelNames = new std::string[2];
levelNames[0] = std::string("pass"); // level 1
levelNames[1] = std::string("fail"); // level 2
// First row (this one determines column types).
std::vector<ColDatum> row1(numCol);
row1[0].setStringValue("a&quo...