elco_elco_convert: Converts the unit of objects of class 'elco'.

View source: R/elco_elco_convert.R

elco_elco_convertR Documentation

Converts the unit of objects of class elco.

Description

elco_elco_convert takes an object of class elco and converts it measurement unit to a specified unit.

Usage

elco_elco_convert(x, to, sample_mass = NULL)

Arguments

x

An object of class elco().

to

A character value representing the unit of measurement to which the element contents should be transformed. This can be any combinations of masses and molar amounts (e.g. "g", "mol", "g/g", "mol/g").

sample_mass

Optionally. A numeric vector of class quantities::quantities() with the same length as x that contains the mass of the corresponding samples. This is used for all unit conversions that require the sample mass, for example to convert from a mass fraction [g/g] to molar amount [mol].

Value

x with converted element contents.

Examples

elco_elco_convert(elco::chno$C, to = "mol/g")

# unit conversion where specifying the sample mass is needed
library(quantities)

elco_elco_convert(
  elco::chno$C,
  to = "mol",
  sample_mass = quantities::set_quantities(1, "g", errors = 0)
)


henningte/elco documentation built on May 21, 2022, 6:56 p.m.