Displaying 2 results from an estimated 2 matches for "byobject".
Did you mean:
pyobject
2012 Jan 10
1
Converting BY to a data.frame
...,sep="_")),
function(x) {
data.frame(
name=as.character(x$name),
a=x$a,
b=x$b,
c=x$a + x$b)
}
)
I made this function:
convertByToDataFrame <- function( byObject ) {
data.frame(matrix(unlist(byObject),nrow=length(byObject),ncol=length(byObject[[1]]),byrow=TRUE,dimnames=list(NULL,names(byObject[[1]]))))
}
but when I run it:
convertByToDataFrame(exampleBY)
I either: (1) loose the types of the different values in the BY, or 2) get factors instead of the va...
2010 Aug 30
4
different interface to by (tapply)?
dear R experts:
has someone written a function that returns the results of by() as a
data frame? ??of course, this can work only if the output of the
function that is an argument to by() is a numerical vector.
presumably, what is now names(byobject) would become a column in the
data frame, and the by object's list elements would become columns.
it's a little bit like flattening the by() output object (so that the
name of the list item and its contents become the same row), and
having the right names for the columns. ?I don't know...