[R] (no subject)

Catalin Roibu c@t@||nro|bu @end|ng |rom gm@||@com
Thu Apr 18 14:57:10 CEST 2019


Dear R users,

I want to compute a nlm for each plot an species and after that to save the
regression coef for each species and plot.
Thanks for your help!

I tried something like this

s<-data.frame(unique(ah$sp))
pl<-data.frame(unique(ah$plot))
z<-data.frame(matrix(nrow=0, ncol=5))

for(i in 1:nrow(pl)){
  t1<-filter(ah, plot==pl[i,1])
  for(j in 1:nrow(s)){
    if (t1$sp==s[j,1]) {
      fo<-h~a+b*log(dbh)+c*(log(dbh))^2+1.3
      st1<-expand.grid(a = seq(-100, 100, len = 4),b = seq(-100, 100, len =
4), c = seq(-1, 1, len = 4))
      mo<-nls2(fo, data=t1,start =st1, control = nls.control(warnOnly =
TRUE))
      sumh<-summary(mo)
} else {
  NA
}
    A<-data.frame(t(coef(mo)))
    A$sp<-rep(s[j,1], nrow(A))
    A$plot<-rep(pl[i,1], nrow(A))
    z<-rbind(z, A)
    plotfit(mo, smooth = TRUE)
  }
}

My data is: ah

plot no sp dbh h
Sinca 1 Br 47.25 42
Sinca 2 Br 17 12.1
Sinca 3 Br 7.5 5.7
Sinca 6 Br 19.25 17.9
Sinca 7 Br 16 12.5
Sinca 9 Br 20.75 15.7
Sinca 11 Br 24.25 23.8
Sinca 12 Br 6 4.6
Sinca 4 Fa 66.5 42.2
Sinca 10 Fa 80 37.3
Sinca 14 Fa 87.75 43.2
Sinca 15 Fa 11.25 9.2
Sinca 18 Fa 12.75 9.5
Sinca 20 Fa 13.25 13.9
Sinca 24 Fa 96 45.3
budeni 1 Fa 92 36.6
budeni 2 Fa 69 28.5
budeni 3 Fa 58.75 29.7
budeni 4 Fa 16.75 11.6
budeni 5 Fa 42.5 35.9
budeni 6 Fa 58.5 40.8
budeni 8 Fa 4 6.9
Ceahlau 215 Mo 33.5 21.9
Ceahlau 216 Mo 32 22.7
Ceahlau 217 Mo 29.5 18.7
Ceahlau 218 Mo 36.5 20.3
Ceahlau 220 Mo 43.5 21.6
Ceahlau 221 Mo 29 18
Ceahlau 222 Mo 25 20
Ceahlau 223 Mo 25 16.4
Ceahlau 224 Mo 35 20.1

-- 

-
-
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone      +4 0230 52 29 78, ext. 531
mobile phone    +4 0745 53 18 01
FAX:                +4 0230 52 16 64
silvic.usv.ro <http://www.usv.ro/>


[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
18.04.19,
15:56:09

	[[alternative HTML version deleted]]



More information about the R-help mailing list