##- Data, diameters at different stem heights
df <- data.frame(hl = c(0.3, 3.9, 7), dl = c(40, 20, 10))
df
##- Cilinder, needs a single diameter and height
dst <- df$dl[1]
hst <- df$hl[1]
## output in cubic centimeters
volume(form = "cilinder", d = dst, l = hst, o.u = "cm3")
## in meters
volume(form = "cilinder", d = dst, l = hst, o.u = "m3")
##- Trapesoid between first and second measurement,
## thus is for a single section.
dl.a <- df$dl[c(1, 2)]
hl.a <- df$hl[c(1, 2)]
vs1<-volume(h = hl.a, d = dl.a)
vs1
##- Trapesoid, between first and third measurement
## thus is for a single section.
dl.b <- df$dl[c(1, 3)]
hl.b <- df$hl[c(1, 3)]
volume(h = hl.b, d = dl.b)
dl.b <- df$dl[c(2, 3)]
hl.b <- df$hl[c(2, 3)]
vs2<-volume(h = hl.b, d = dl.b)
vs2
vs1+vs2
##- Newton (only possible if three measurements are given)
volume(form = "newton", h = df$hl, d = df$dl)
##- Huber, for all available measurements
volume(form = "huber", d = df$dl, h = df$hl)
##- Huber given 1 diameter and 1 distance
l.a <- diff(c(df$hl[1], df$hl[3]))
volume(form = "huber", d = df$d[2], l = l.a)
Run the code above in your browser using DataLab