Hello,
I want to sum first three terms of each column of matrix.
But I don't calculate with "apply" function.
skwkrt<-function(N=10000,mu=0,sigma=1,n=100,
nboot=1000,alpha=0.05){
x<-rnorm(N,mu,sigma)#population
samplex<-matrix(sample(x,n*nboot,replace=T),nrow=nboot)
#...
}
is that: suppose a is a 5x2 matrix.
a={1,2,3,4,5
6,7,8,9,10}
I want to sum first three terms.
sm[1]=1+2+3
sm[2]=6+7+8
But I don't calculate. please help me!!!
[[alternative HTML version deleted]]
Your message is severely garbled. However a={1,2,3,4,5 6,7,8,9,10}
is not going to work since {} is incorrect. you need c()
Anyway try this:
a=matrix(1:10,ncol=2)
sum(a[1:3,1])
sum(a[1:3,2])
--- On Sun, 4/3/11, mustafabinar <mustafa_binar at mynet.com> wrote:
> From: mustafabinar <mustafa_binar at mynet.com>
> Subject: [R] :HELP
> To: r-help at r-project.org
> Received: Sunday, April 3, 2011, 9:10 AM
> Hello,
>
> I want to sum first three terms of each column of matrix.
> But I don't calculate with "apply" function.
>
> skwkrt<-function(N=10000,mu=0,sigma=1,n=100,
> nboot=1000,alpha=0.05){
> x<-rnorm(N,mu,sigma)#population
> samplex<-matrix(sample(x,n*nboot,replace=T),nrow=nboot)
> #...
> }
>
> is that: suppose a is a 5x2 matrix.
> a={1,2,3,4,5
> 6,7,8,9,10}
>
> I want to sum first three terms.
> sm[1]=1+2+3
> sm[2]=6+7+8
> But I don't calculate. please help me!!!
>
> ??? [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>
Hi: Is this what you're after? x <- matrix(1:10, nrow = 2, byrow = TRUE) rowSums(x[, 1:3]) HTH, Dennis PS: This list expects submissions to be in text, not HTML. See the Posting Guide, please. On Sun, Apr 3, 2011 at 6:10 AM, mustafabinar <mustafa_binar@mynet.com>wrote:> Hello, > > I want to sum first three terms of each column of matrix. > But I don't calculate with "apply" function. > > skwkrt<-function(N=10000,mu=0,sigma=1,n=100, > nboot=1000,alpha=0.05){ > x<-rnorm(N,mu,sigma)#population > samplex<-matrix(sample(x,n*nboot,replace=T),nrow=nboot) > #... > } > > is that: suppose a is a 5x2 matrix. > a={1,2,3,4,5 > 6,7,8,9,10} > > I want to sum first three terms. > sm[1]=1+2+3 > sm[2]=6+7+8 > But I don't calculate. please help me!!! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]