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
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
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
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
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,
5 matches
Mail list logo