Hi,
You could reduce those steps by:
as.data.frame(do.call(rbind,a2))
A.K.
- Original Message -
From: Abdul Rahman bin Kassim (Dr.)
To: John Kane ; "r-help@r-project.org"
Cc:
Sent: Friday, May 31, 2013 11:47 AM
Subject: Re: [R] Returning combine output from R loop
Dear Kane,
Great and thanks for the do.call function.
Abd Rahman
From: arun [smartpink...@yahoo.com]
Sent: Saturday, June 01, 2013 12:23 AM
To: Abdul Rahman bin Kassim (Dr.)
Cc: R help; John Kane
Subject: Re: [R] Returning combine output from R loop
Hi
-
Abd Rahman
From: John Kane [jrkrid...@inbox.com]
Sent: Friday, May 31, 2013 10:33 PM
To: Abdul Rahman bin Kassim (Dr.); r-help@r-project.org
Subject: RE: [R] Returning combine output from R loop
One way is to put them in a list.
Does this help?
a0 <- data.frame(initial_size=sample(30,1
One way is to put them in a list.
Does this help?
a0 <- data.frame(initial_size=sample(30,10),sp=gl(2,5,10),
grow=as.numeric(as.character(gl(2,5,10)))*0.5)
a2<- list()
for( i in 1:3){
a1 <- a0$initial_size+a0$grow
a2[[i]] <- cbind(sp=a0$sp,initial_size=a1+i,yr=i)
}
John Kane
Kingsto
: Friday, May 31, 2013 4:12 PM
To: Abdul Rahman bin Kassim (Dr.); r-help@r-project.org
Subject: RE: [R] Returning combine output from R loop
In line with what you are doing now, but saving the intermediate results
you could use something like this.
a3 <- a0
for( i in 1:3)
{
a1 <- a0$initial_s
In line with what you are doing now, but saving the intermediate results
you could use something like this.
a3 <- a0
for( i in 1:3)
{
a1 <- a0$initial_size+a0$grow
a2<- cbind(sp=a0$sp,initial_size=a1+i,yr=i)
a3 <- cbind(a3, a2)
}
a3
However, I would suggest one of the following solutions i
6 matches
Mail list logo