construction_decimal: Construction Decimal

construction_decimalR Documentation

Construction Decimal

Description

Convert a construction measurement in US Customary Units (foot + inch) with or without a fraction into its equivalent as a decimal

Usage

construction_decimal(
  measurement,
  result = c("traditional", "librecad"),
  output = c("vector", "table")
)

Arguments

measurement

character vector that contains the construction measurement (foot + inch)

result

character vector that contains the decimal type options are traditional (ex. 1.203125 = 1'-2 7/16\" where the whole number is the value in ft and the decimal is the value in inches & librecad (ex. 14.43112 = 1'-2 7/16\"), whereby LibreCAD defines its decimal unit as "integer part separated from the fractional part of a number by a decimal". Thus, both the whole number and the decimal is the value in inches.

output

character vector that contains the type of output. The options are vector (just the single value as a decimal) and table the decimal value in inch (in), feet (ft), yard (yd), millimeters (mm), centimeters (cm), and meters (m).

Value

the construction measurement value as a numeric vector as a decimal or as a table (depends on the output parameters)

Note

If you only have a measurement in inches, then use frac_to_numeric instead.

Author(s)

Irucka Embry

Source

  1. removing all non-numeric characters from a string, but not "." - R help on nabble.com answered by David Winsemius on Jul 26, 2016. See https://web.archive.org/web/20190730141421/http://r.789695.n4.nabble.com/removing-all-non-numeric-characters-from-a-string-but-not-quot-quot-td4723146.html. Retrieved thanks to the Internet Archive: Wayback Machine

  2. r - How to not run an example using roxygen2? - Stack Overflow answered and edited by samkart on Jul 9 2017. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/12038160/how-to-not-run-an-example-using-roxygen2.

  3. devtools - Issues in R package after CRAN asked to replace dontrun by donttest - Stack Overflow answered by Hong Ooi on Sep 1 2020. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/63693563/issues-in-r-package-after-cran-asked-to-replace-dontrun-by-donttest.

  4. regex - Replace single backslash in R - Stack Overflow answered and edited by Hong Ooi on Aug 21, 2014. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/25424382/replace-single-backslash-in-r.

References

  1. LibreCAD v2.2.0 - User Manual - Fundamentals: Units, 7 May 2022, https://librecad-docs-dev.readthedocs.io/en/latest/ref/fundamentals.html#units.

  2. Spike, 1 January 2022, "Foot and Inch to Decimal Format Conversion", https://www.spikevm.com/calculators/fraction-decimal-calculators.php.

Examples


# Please refer to the iemisc: Construction Measurement Examples vignette for
# additional examples

# Example 1

library(iemisc)

construction_decimal("2'-0\"", result = "traditional", output = "vector")

construction_decimal("1'-2 7/16\"", result = "librecad", output = "vector")



# Example 2

library(iemisc)

construction_decimal("0 6", result = "traditional", output = "vector")

construction_decimal("0 6", result = "librecad", output = "vector")



# Example 3

library(iemisc)

tss1 <- "48'-0 1/2\""
tss2 <- "56-9 1/2\""

sum(construction_decimal(tss1, result = "traditional", output = "vector"),
construction_decimal(tss2, result = "traditional", output = "vector"))



# See Source 2 and Source 3

# Example 4

library(iemisc)

try(construction_decimal(5, result = "traditional", output =
"vector")) # please see the error message

ex_error <- character(0)
try(construction_decimal(ex_error, result = "traditional",
output = "vector")) # please see the error message

try(construction_decimal(NA, result = "traditional", output =
"vector")) # please see the error message

try(construction_decimal("feet", result = "traditional", output =
"vector")) # please see the error message




# Example 5

library(iemisc)

app1 <- "5' 2\""

app2 <- "6' 3\""

app3 <- construction_decimal(app1, result = "traditional", output = "vector") *
construction_decimal(app2, result = "traditional", output = "vector")
app3

# If you want to have the fractional value using 16ths, do the following:

construction_fraction(app3, type = "traditional", result = "traditional",
fraction = 16)






iemisc documentation built on Sept. 25, 2023, 5:09 p.m.