Commit a4c8132f authored by Holger Brandl's avatar Holger Brandl

cosmetics

parent 941e849e
......@@ -178,8 +178,9 @@ print_head <- function(df, desc=NULL){
fac2char <- function(mydata, convert=names(mydata)[sapply(mydata, is.factor)]){
if(length(convert)==0)
return(mydata)
if(length(convert)==0){
return(mydata)
}
inputColOrder <- names(mydata)
......@@ -333,26 +334,28 @@ rmLastElement <- function(vec) vec[-length(vec)]
# improved list of objects
lsos <- function (pos = 1, pattern, order.by,
decreasing=FALSE, head=FALSE, n=5) {
napply <- function(names, fn) sapply(names, function(x)
fn(get(x, pos = pos)))
lsos <- function (pos = 1, pattern, order.by, decreasing=FALSE, head=FALSE, n=5) {
napply <- function(names, fn) sapply(names, function(x) fn(get(x, pos = pos)))
names <- ls(pos = pos, pattern = pattern)
obj.class <- napply(names, function(x) as.character(class(x))[1])
obj.mode <- napply(names, mode)
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
obj.size <- napply(names, object.size)/1000000
obj.dim <- t(napply(names, function(x)
as.numeric(dim(x))[1:2]))
vec <- is.na(obj.dim)[, 1] & (obj.type != "function")
obj.dim[vec, 1] <- napply(names, length)[vec]
out <- data.frame(obj.type, obj.size, obj.dim)
names(out) <- c("Type", "Size", "Rows", "Columns")
if (!missing(order.by))
out <- out[order(out[[order.by]], decreasing=decreasing), ]
if (head)
out <- head(out, n)
# out
if (head) out <- head(out, n)
out <- transform(out, var_name=rownames(out))
rownames(out) <- NULL
arrange(out, Size)
......@@ -373,4 +376,4 @@ trim_outliers <- function(values, range=quantile(values, c(0.05, 0.95))) pmax(r
## use trim_outliers instead
#limit_range <- function(values, range) pmax(range[1], pmin(range[2], values))
se<-function(x) sd(x, na.rm=TRUE) / sqrt(sum(!is.na(x)))
se <- function(x) sd(x, na.rm=TRUE) / sqrt(sum(!is.na(x)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment