-1

I am using the following loop to output the growth parameters/coefficients 'L infinity' and 'K', I would like to know if there is a way that I can get the code to output the printed values into a df, as there are over 400 different Haul_IDs and copying them individually from the output will take me an age.

 for(a in unique(growth$Haul_ID)) { 
 svTypical <- vbStarts(Height_t2~t2,data=growth[growth$Haul_ID==a,],plot=FALSE) #can add or remove plot=TRUE
 print(a)
 print(svTypical)
 unlist(svTypical) #unlist to save space when viewing results
 }

In the dataframe all I need is;

Haul ID      L infinity      K 
helen.h
  • 943
  • 2
  • 7
  • 18
  • It would help if you made your situation [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Will Beason Sep 01 '14 at 16:06
  • If you edit your post to include a *minimal* example that other people (who do not have your data...) can run - you will get more answers of a higher quality, and more quickly, than if you provide none. Just copying and pasting your working code is pretty lazy...and not the suggested method for a good question post. just sayin' – Rusan Kax Sep 01 '14 at 16:17

1 Answers1

0

Following may be helpful:

ddf = data.frame(Haul_ID = as.character(), L =as.numeric(), infinity= as.numeric(),  K=as.numeric())
for(i in 1:length(unique(growth$Haul_ID))){
    # your code to get 'a' and 'svTypical'
    ddf[i,]=c(a,unlist(svTypical))
}
ddf
rnso
  • 23,686
  • 25
  • 112
  • 234