Re: [R] dataframe to list conversion

2009-07-27 Thread Jorge Ivan Velez
Dear voidobscura, Try also Csum <- function(x) apply(x, 2, sum) Csum(m) HTH, Jorge On Mon, Jul 27, 2009 at 11:03 AM, voidobscura <> wrote: > > Hi all, I have been experimenting with writing my own matrix column sum > function. I want it to return a list. > > csum<-function(m) > { >a = da

Re: [R] dataframe to list conversion

2009-07-27 Thread Bill.Venables
obscura Sent: Tuesday, 28 July 2009 1:04 AM To: r-help@r-project.org Subject: [R] dataframe to list conversion Hi all, I have been experimenting with writing my own matrix column sum function. I want it to return a list. csum<-function(m) { a = data.frame(m) s = lapply(a,sum) ret

Re: [R] dataframe to list conversion

2009-07-27 Thread Jorge Ivan Velez
Hi voidobscura, Try either csum2 <- function(m){ a = data.frame(m) s = lapply(a,sum) do.call(c, s) } or colSums(m) See ?do.call and ?colSums for more details. HTH, Jorge On Mon, Jul 27, 2009 at 11:03 AM, voidobscura wrote: > > Hi all, I have been experimenting with writing my own

Re: [R] dataframe to list conversion

2009-07-27 Thread Dimitris Rizopoulos
have a look at ?unlist(); you can also use sapply() in this case instead of lapply(). Best, Dimitris voidobscura wrote: Hi all, I have been experimenting with writing my own matrix column sum function. I want it to return a list. csum<-function(m) { a = data.frame(m) s = lapply(a,s

[R] dataframe to list conversion

2009-07-27 Thread voidobscura
Hi all, I have been experimenting with writing my own matrix column sum function. I want it to return a list. csum<-function(m) { a = data.frame(m) s = lapply(a,sum) return(s) } I wish to use the same code up until the return(s) that I have listed above. The problem is that s,