Displaying 1 result from an estimated 1 matches for "convertbytodataframe".
2012 Jan 10
1
Converting BY to a data.frame
...by(exampleDF,with(exampleDF,paste(a,b,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...