[R] data export HELP!

jim holtman jholtman at gmail.com
Sun Jul 11 22:20:27 CEST 2010


Not necessarily the best way if your dataframe will get large, but it
should work:

parameters <- NULL  # where you will collect the result
for(j in 1:dim(r)[2]){
       indiv=r[,j][which(r[,j]>-1)] #removes -1 growth data
       age.1=age[1:length(indiv)]
       length.ind=data.frame(age.1,indiv, row.names=TRUE) #data frame of
ages and length


est.ind=nls(indiv~Linf*(1-exp(-K*(age.1-to))),start=lkt.A,data=length.ind) #
von b growth estimate
       summary=summary(est.ind, correlation=TRUE) #gives parameter estimate
values


       parameters <- rbind(parameters,
data.frame("Linf"=coef(est.ind)[1],"K"=coef(est.ind)[2]))
#data frame of parameter estimates

       }

On Sun, Jul 11, 2010 at 3:54 PM, adriana1986 <adriana.olijnyk at queensu.ca> wrote:
>
> Hello!
> So, this is going to seem like a very simple question - I am quite new to R
> and am having some trouble figuring out little nuances:
>
> I am running a loop that goes through my data and performs a nls parameter
> estimation on each data set. At the end of the loop, I would like to collect
> the parameter estimates in ONE SINGLE DATA FRAME or WRITE.TABLE that I can
> import into excel.
>
> Here is my code:
>
>
> for(j in 1:dim(r)[2]){
>        indiv=r[,j][which(r[,j]>-1)] #removes -1 growth data
>        age.1=age[1:length(indiv)]
>        length.ind=data.frame(age.1,indiv, row.names=TRUE) #data frame of
> ages and length
>
>
> est.ind=nls(indiv~Linf*(1-exp(-K*(age.1-to))),start=lkt.A,data=length.ind) #
> von b growth estimate
>        summary=summary(est.ind, correlation=TRUE) #gives parameter estimate
> values
>
>
>        parameters=data.frame("Linf"=coef(est.ind)[1],"K"=coef(est.ind)[2])
> #data frame of parameter estimates
>
>        }
>
> if I just type "parameters" I only get the parameter estimates for the LAST
> individual that was in the loop. How can i combine EVERY SINGLE parameter
> estimate into a data.frame or something of the sort and then export this set
> of data into ONE csv file. I can do it using write.table within my loop, but
> then I get 52 csv files -  I would like to avoid this.
>
> I hope this makes sense - any help would be GREATLY APPRECIATED!!!!
>
> thanks!
> --
> View this message in context: http://r.789695.n4.nabble.com/data-export-HELP-tp2285445p2285445.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list