Difference between revisions of "OpasnetUtils/Drafts"

From Testiwiki
Jump to: navigation, search
(Answer: corrected typo in suomenna)
(Answer)
Line 457: Line 457:
 
temp <- as.factor(obj@output[[cols[i]]])
 
temp <- as.factor(obj@output[[cols[i]]])
 
location_weight_order <- order(result(test2), decreasing = TRUE)
 
location_weight_order <- order(result(test2), decreasing = TRUE)
if (bins[i] <= nrow(test2@output)) {
+
keeps <- test2@output[[cols[i]]][location_weight_order[0:min(bins[i] - 1, nrow(test2@output))]]
keeps <- test2@output[[cols[i]]][location_weight_order[0:(bins[i] - 1)]]
+
levels(temp)[!levels(temp) %in% keeps] <- "Other"
levels(temp)[!levels(temp) %in% keeps] <- "Other"
+
temp <- factor(temp, levels = c(levels(temp)[levels(temp) != "Other"], "Other"))
temp <- factor(temp, levels = c(levels(temp)[levels(temp) != "Other"], "Other"))
+
obj@output[[cols[i]]] <- temp
obj@output[[cols[i]]] <- temp
 
}
 
 
}
 
}
# After changing some locations to "Other", sum along indices to avoid problems
+
# After changing some locations to "Other", sum along indices to avoid problems
 
if(sum_others) {
 
if(sum_others) {
# ind <- colnames(obj@output)[obj@marginal | colnames(obj@output) %in% cols]
 
 
obj <- oapply(obj, cols = "", FUN = sum, na.rm = TRUE)
 
obj <- oapply(obj, cols = "", FUN = sum, na.rm = TRUE)
 
}
 
}

Revision as of 11:41, 27 July 2015



Question

Which functions are so useful that they should be taken into OpasnetUtils package? This page contains draft function which will be included when they are good enough and found important.

Answer

Call the objects stored by this code from another rode with this command:

objects.latest("Op_en6007", code_name = "answer")

+ Show code

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>