Learn R Programming

biometrics (version 1.0.3)

volume: Compute volume of objects

Description

Calculate the volume of objects, depending on their shapes or available measurements, to carry out the computation.

Usage

volume(
  form = "trapesoid",
  d = NA,
  h = NA,
  l = NA,
  d.u = "cm",
  h.u = "m",
  l.u = "m",
  o.u = "m3"
)

Value

Value of volume.

Arguments

form

string indicating the form of the object to be cubicated. The alternatives are the following: cone, cilinder, trapesoid (also know as the Smalian's cubic formula), newton, or huber.

d

vector of diameter values.

h

vector of height values.

l

Distance, generally the difference between two h values. If l is given, h must not be given.

d.u

string indicating the unit of d. Can be any of cm (default), in, m or ft.

h.u

string indicating the unit of h. Can be any of cm, in, m (default) or ft.

l.u

string indicating the unit of l. Can be any of cm, in, m (default) or ft.

o.u

string indicating the unit of the calculated volume. Can be any of cm3, in3, m3 (default) or ft3.

Author

Christian Salas-Eljatib and Nicolás Campos and Victor Pacheco

Examples

Run this code
##- 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