On Thu, Dec 24, 2009 at 4:38 AM, Brian G. Peterson wrote:
>
> data <- matrix(rnorm(100), nrow=10) # 10 x 10
> apply(data,2,cumsum)
>
> if you want to store the partial sums
> (that was an important bit of information you left out)
>
>
Thank you for your suggestion. However, I gave information onl
Francesco Napolitano wrote:
Il giorno mer, 23/12/2009 alle 22.14 -0500, David Winsemius ha scritto:
for(i in 1:n){
submat <- data[1:i,]
C <- colSums(submat)
}
In R the loop is not necessary, even confusing as you are demonstrating:
> mat <- matrix(rnorm(100), nrow=10) # 10 x 10
>
Il giorno mer, 23/12/2009 alle 22.14 -0500, David Winsemius ha scritto:
> > for(i in 1:n){
> >submat <- data[1:i,]
> >C <- colSums(submat)
> >}
> >
> In R the loop is not necessary, even confusing as you are demonstrating:
>
> > mat <- matrix(rnorm(100), nrow=10) # 10 x 10
> > colSu
So I see from help([[) what's happening: thank you very much.
Il giorno mer, 23/12/2009 alle 18.59 -0800, Henrik Bengtsson ha scritto:
> Use
>
>submat <- data[1:i,, drop=FALSE]
>
> /H
>
> On Wed, Dec 23, 2009 at 6:46 PM, Francesco Napolitano
> wrote:
> > Hi all,
> >
> > I'm trying to learn
On Dec 23, 2009, at 9:46 PM, Francesco Napolitano wrote:
Hi all,
I'm trying to learn R after years of Matlab's experience. Here is an
issue I couldn't solve today.
Consider the following piece of code (written by memory):
for(i in 1:n){
submat <- data[1:i,]
C <- colSums(submat)
}
Use
submat <- data[1:i,, drop=FALSE]
/H
On Wed, Dec 23, 2009 at 6:46 PM, Francesco Napolitano
wrote:
> Hi all,
>
> I'm trying to learn R after years of Matlab's experience. Here is an
> issue I couldn't solve today.
>
> Consider the following piece of code (written by memory):
>
> for(i in 1
replace data[1:i,] by data[1:i,drop=FALSE].
b
On Dec 24, 2009, at 12:46 AM, Francesco Napolitano wrote:
> Hi all,
>
> I'm trying to learn R after years of Matlab's experience. Here is an
> issue I couldn't solve today.
>
> Consider the following piece of code (written by memory):
>
> for(i in
Hi all,
I'm trying to learn R after years of Matlab's experience. Here is an
issue I couldn't solve today.
Consider the following piece of code (written by memory):
for(i in 1:n){
submat <- data[1:i,]
C <- colSums(submat)
}
The problem is that at the first iteration, data[1:1,] redu
8 matches
Mail list logo