| Title: | Irucka Embry's Miscellaneous Functions |
|---|---|
| Description: | A collection of Irucka Embry's miscellaneous functions (Engineering Economics, Civil & Environmental/Water Resources Engineering, Construction Measurements, GNU Octave compatible functions, Python compatible function, Trigonometric functions in degrees and function in radians, Geometry, Statistics, Mortality Calculators, Quick Search, etc.). |
| Authors: | Irucka Embry [aut, cre], Felix Andrews [aut, ctb] (zoo code), Hans Werner Borchers [aut, ctb] (pracma code), Samit Basu [aut, ctb] (FreeMat code), David Bateman [aut, ctb] (GNU Octave code), Rik Wehbring [aut, ctb] (GNU Octave code), Didier Clamond [aut, ctb] (MATLAB code), Berry Boessenkool [aut, ctb] (checkLL and degree functions from OSMscale), Tyler Rinker [aut, ctb] (lookup and lookup_helper functions from qdapTools), Colin Caprani [aut, ctb] (secprop MATLAB function), Teodor Ciuraru [aut, ctb] (stackoverflow R code), Dylan Russell [aut, ctb] (stackoverflow R code), John Wallace [aut, ctb] (stackoverflow R code), kaijagahm [aut, ctb] (R bloggers R code), Colin B. Macdonald [aut, ctb] (OctSymPy code), John D Page [aut, ctb] (JavaScript code), Josh O'Brien [aut, ctb] (stackoverflow R code), R. van Twisk [aut, ctb] (LibreCAD code) |
| Maintainer: | Irucka Embry <[email protected]> |
| License: | GPL (>= 3) | file LICENSE |
| Version: | 1.0.6 |
| Built: | 2026-10-05 06:47:08 UTC |
| Source: | https://gitlab.com/iembry/iemisc |
Performs floor (or integer) division on 2 numeric vectors.
x %//% yx %//% y
x |
numeric vector |
y |
numeric vector |
The integral part of the quotient is returned.
Irucka Embry
Jakub Przywóski: "Python Reference (The Right Way)". // floor division, 2015, Revision 9a3b94e7, https://python-reference.readthedocs.io/en/latest/docs/operators/floor_division.html.
# Example 1 -- From the Python reference library(iemisc) 5.0 / 2 # 2.5 5.0 %//% 2 # 2.0# Example 1 -- From the Python reference library(iemisc) 5.0 / 2 # 2.5 5.0 %//% 2 # 2.0
This function preserves the original order (sequence) of character vectors.
y %inorder% tabley %inorder% table
y |
numeric vector that contains the sequence to return |
table |
character vector, data.table, and/or tibble that has the character values to be checked within |
character vector with the characters in the original sequence
John Wallace (Stack Overflow R code), Irucka Embry
R - preserve order when using matching operators (
# Examples (from the Source) LETTERS[1:26 %in% 4:1] LETTERS[1:26 %inorder% 4:1] LETTERS[1:26 %in% 3:-5] LETTERS[1:26 %inorder% 3:-5] data.frame(letters, LETTERS)[1:5 %in% 3:-5, ] data.frame(letters, LETTERS)[1:5 %inorder% 3:-5, ] library(data.table) data.table(letters, LETTERS)[1:5 %inorder% 3:-5, ] library(tibble) tibble(letters, LETTERS)[1:5 %inorder% 3:-5, ]# Examples (from the Source) LETTERS[1:26 %in% 4:1] LETTERS[1:26 %inorder% 4:1] LETTERS[1:26 %in% 3:-5] LETTERS[1:26 %inorder% 3:-5] data.frame(letters, LETTERS)[1:5 %in% 3:-5, ] data.frame(letters, LETTERS)[1:5 %inorder% 3:-5, ] library(data.table) data.table(letters, LETTERS)[1:5 %inorder% 3:-5, ] library(tibble) tibble(letters, LETTERS)[1:5 %inorder% 3:-5, ]
This function performs a quick, case sensitive search of character vectors
that are not in a set of character vectors or a quick, search of numeric
vectors that are not in a set of numeric vectors using Negate chin
for character vectors and Negate in for numeric vectors
x %notchin% yx %notchin% y
x |
character or numeric vector that contains the values to not be matched |
y |
character or numeric vector that has the values to be checked within |
'Utilizes chin from data.table to quickly complete a case insensitive search through a character vector to return a logical vector of string detections. Will always return TRUE or FALSE for each position of string regardless of NA missing values in either provided vector. NA in string will never match an NA value in the vector.'
logical vector the length of the original string (x). TRUE means that x is not in y and FALSE means that x is in y
kaijagahm (R code), Irucka Embry
The
# Examples x <- c("apple", "banana", "cherry", NA) "apple" %notchin% x c("apple", "BANANA", "coconut", NA) %notchin% x x "a" %notchin% letters[5:20] letters[5:20] %notchin% "a" "a" %notchin% LETTERS LETTERS %notchin% "a" 1 %notchin% -12:20 -12:20 %notchin% 1# Examples x <- c("apple", "banana", "cherry", NA) "apple" %notchin% x c("apple", "BANANA", "coconut", NA) %notchin% x x "a" %notchin% letters[5:20] letters[5:20] %notchin% "a" "a" %notchin% LETTERS LETTERS %notchin% "a" 1 %notchin% -12:20 -12:20 %notchin% 1
This function performs a quick, case insensitive search of strings
string %qsin% vectorstring %qsin% vector
string |
character vector that contains the values to match |
vector |
character vector that has the values to be matched against |
'Utilizes chin from data.table to quickly complete a case insensitive search through a character vector to return a logical vector of string detections. Will always return TRUE or FALSE for each position of string regardless of NA missing values in either provided vector. NA in string will never match an NA value in the vector.'
logical vector the length of the original string
Dylan Russell (stackoverflow code, examples, and function details, function description), Irucka Embry
data.table - R case-insensitive %in% - Stack Overflow answered and edited by Dylan Russell on Sep 13, 2020. See https://stackoverflow.com/questions/63874824/r-case-insensitive-in.
# Examples x <- c("apple", "banana", "cherry", NA) "apple" %qsin% x c("APPLE", "BANANA", "coconut", NA) %qsin% x# Examples x <- c("apple", "banana", "cherry", NA) "apple" %qsin% x c("APPLE", "BANANA", "coconut", NA) %qsin% x
Calculates the value of inverse cosine for each element of x in
degrees in a manner compatible with GNU Octave/MATLAB.
acosd(x)acosd(x)
x |
A numeric vector containing values in degrees |
The inverse cosine of each element of x in degrees.
David Bateman (GNU Octave acosd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
acos if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave acosd acosd (seq(0, 1, by = 0.1))library(iemisc) # Examples from GNU Octave acosd acosd (seq(0, 1, by = 0.1))
Calculates the value of inverse cotangent for each element of x in
degrees in a manner compatible with GNU Octave/MATLAB.
acotd(x)acotd(x)
x |
A numeric vector containing values in degrees |
The inverse cotangent of each element of x in degrees.
David Bateman (GNU Octave acotd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
atan if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave acotd acotd (seq(10, 90, by = 10))library(iemisc) # Examples from GNU Octave acotd acotd (seq(10, 90, by = 10))
Calculates the value of inverse cosecant for each element of x in
degrees in a manner compatible with GNU Octave/MATLAB.
acscd(x)acscd(x)
x |
A numeric vector containing values in degrees |
The inverse cosecant of each element of x in degrees.
David Bateman (GNU Octave acscd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
acsc if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave acscd acscd (seq(0, 90, by = 10))library(iemisc) # Examples from GNU Octave acscd acscd (seq(0, 90, by = 10))
Compute A given F
AgivenF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) AF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )AgivenF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) AF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
F |
numeric vector that contains the future value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
A is expressed as
the "uniform series amount (occurs at the end of each interest period)"
the "future equivalent"
the "effective interest rate per interest period"
the "number of interest periods"
AgivenF numeric vector that contains the annual value(s) rounded to 2 decimal places
AF data.frame of both n (0 to n) and the resulting annual values rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 135-136, 142, 164.
library(iemisc) # Example for equation 4-12 from the Reference text (pages 135-136) AgivenF(309*10^6, 60, 0.5, "month") # the interest rate is 0.5\% per month and n is 60 months # "$4.4187 million per month" is the answer AF(309*10^6, 60, 0.5, "annual") # the interest rate is 0.5\% per month and n is 60 monthslibrary(iemisc) # Example for equation 4-12 from the Reference text (pages 135-136) AgivenF(309*10^6, 60, 0.5, "month") # the interest rate is 0.5\% per month and n is 60 months # "$4.4187 million per month" is the answer AF(309*10^6, 60, 0.5, "annual") # the interest rate is 0.5\% per month and n is 60 months
Compute A given F with interest compounded continuously
AgivenFcont(F, n, r)AgivenFcont(F, n, r)
F |
numeric vector that contains the future value(s) |
n |
numeric vector that contains the period value(s) |
r |
numeric vector that contains the continuously compounded nominal annual interest rate(s) as a percent |
A is expressed as
the "annual equivalent amount (occurs at the end of each year)"
the "future equivalent"
the "nominal annual interest rate, compounded continuously"
the "number of periods (years)"
AgivenFcont numeric vector that contains the annual value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 169.
library(iemisc) AgivenFcont(300, 2, 11) # 11\% interestlibrary(iemisc) AgivenFcont(300, 2, 11) # 11\% interest
Compute A given G
AgivenG( G, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )AgivenG( G, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
G |
numeric vector that contains the gradient value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
the "uniform series amount (occurs at the end of each interest period)"
the "uniform gradient amount"
the "effective interest rate per interest period"
the "number of interest periods"
AgivenG numeric vector that contains the annual value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 142, 150, 152-154, 164, 166-167.
library(iemisc) # Example 4-20 from the Reference text (pages 153-154) AgivenG(1000, 4, 15, "annual") # the interest rate is 15\% # Example 4-31 from the Reference text (pages 166-167) AgivenG(1000, 4, 20, "semiannual") # the nominal interest rate is 20\% compounded semiannuallylibrary(iemisc) # Example 4-20 from the Reference text (pages 153-154) AgivenG(1000, 4, 15, "annual") # the interest rate is 15\% # Example 4-31 from the Reference text (pages 166-167) AgivenG(1000, 4, 20, "semiannual") # the nominal interest rate is 20\% compounded semiannually
Compute A given P
AgivenP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) AP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )AgivenP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) AP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
A is expressed as
the "uniform series amount (occurs at the end of each interest period)"
the "present equivalent"
the "effective interest rate per interest period"
the "number of interest periods"
AgivenP numeric vector that contains the annual value(s) rounded to 2 decimal places
AP data.frame of both n (0 to n) and the resulting annual values rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 136, 142, 164, 166.
library(iemisc) # Example for equation 4-14 from the Reference text (page 136) AgivenP(17000, 4, 1, "annual") # the interest rate is 1\% per month and n is 4 months AP(17000, 4, 1, "annual") # the interest rate is 1\% per month and n is 4 months # Example 4-30 from the Reference text (page 166) AgivenP(10000, 5, 12, "month") # the interest rate is 12% compounded monthly for 5 years AP(10000, 5, 12, "month") # the interest rate is 12% compounded monthly for 5 yearslibrary(iemisc) # Example for equation 4-14 from the Reference text (page 136) AgivenP(17000, 4, 1, "annual") # the interest rate is 1\% per month and n is 4 months AP(17000, 4, 1, "annual") # the interest rate is 1\% per month and n is 4 months # Example 4-30 from the Reference text (page 166) AgivenP(10000, 5, 12, "month") # the interest rate is 12% compounded monthly for 5 years AP(10000, 5, 12, "month") # the interest rate is 12% compounded monthly for 5 years
Compute A given P with interest compounded continuously
AgivenPcont(P, n, r)AgivenPcont(P, n, r)
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
r |
numeric vector that contains the continuously compounded nominal annual interest rate(s) as a percent |
A is expressed as
the "annual equivalent amount (occurs at the end of each year)"
the "present equivalent"
the "nominal annual interest rate, compounded continuously"
the "number of periods (years)"
AgivenPcont numeric vector that contains the annual value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 169-170.
library(iemisc) # Example for equation 4-34 from the Reference text (page 170) AgivenPcont(1000, 10, 20) # 20\% interestlibrary(iemisc) # Example for equation 4-34 from the Reference text (page 170) AgivenPcont(1000, 10, 20) # 20\% interest
Calculates key parameters needed in the design of a packed column air stripper according to the U.S. Army Corps of Engineers Design Guide No. 1110-1-3: Air Stripping Engineering and Design (Design Guidelines). Please refer to the Design Guidelines for the governing equations and background information.
'Air stripping is the transferring of volatile components of a liquid into an air stream. It is an environmental engineering technology used for the purification of groundwaters and wastewaters containing volatile compounds.' (Reference: Wikipedia)
air_stripper( Temp, pTe, contam1, Cai, Cae, contam2, cas = NULL, Ha, Q, loading, ns, DL, DG, R, P_atm = NULL, dP = NULL, at = NULL, Sc = NULL, cf = NULL, Temp_unit = c("SI", "Eng", "Absolute"), dP_unit = c("inch", "mm"), at_unit = c("ft^2/ft^3", "m^2/m^3"), Sc_unit = c("kg/s^2", "slug/s^2"), contaminants_table = c(0, 1), removal_requirements_table = c(0, 1), critical_contaminant_table = c(0, 1) )air_stripper( Temp, pTe, contam1, Cai, Cae, contam2, cas = NULL, Ha, Q, loading, ns, DL, DG, R, P_atm = NULL, dP = NULL, at = NULL, Sc = NULL, cf = NULL, Temp_unit = c("SI", "Eng", "Absolute"), dP_unit = c("inch", "mm"), at_unit = c("ft^2/ft^3", "m^2/m^3"), Sc_unit = c("kg/s^2", "slug/s^2"), contaminants_table = c(0, 1), removal_requirements_table = c(0, 1), critical_contaminant_table = c(0, 1) )
Temp |
numeric vector that contains the minimum Temperature (degrees Celsius, degrees Fahrenheit, or Kelvin) |
pTe |
numeric vector that contains the total pressure of gas (air) effluent (atm) |
contam1 |
character vector that contains the name of each contaminant to be removed (may include "Total VOCs"). See the example. |
Cai |
numeric vector that contains the concentration of each contaminant in liquid (water) influent (ug/L) |
Cae |
numeric vector that contains the concentration of each contaminant in liquid (water) effluent (ug/L) |
contam2 |
character vector that contains the name of each contaminant (will not include "Total VOCs"). See the example. |
cas |
character vector that contains the CAS Number of each contaminant, if known, otherwise it can be accessed internally |
Ha |
numeric vector that contains the Ha (Henry's Law coefficient) at the minimum Temperature T for each contaminant (atm/mole/mole) |
Q |
numeric vector that contains the sustained pumping rate (gallons per minute or gpm) |
loading |
numeric vector that contains the stripper surface loading (gpm/ft^2) |
ns |
numeric vector that contains the number of strippers |
DL |
numeric vector that contains the liquid diffusivity of each contaminant at the minimum Temperature T in the same order as contam2 (m^2/s) |
DG |
numeric vector that contains the gas diffusivity of each contaminant in air at the minimum Temperature T and pTe in the same order as contam2 (m^2/s) |
R |
numeric vector that contains the stripping factor (R = 2.5 if air pollution control is required or R = 4.5 if it isn't, but in a range of 2 - 5) |
P_atm |
numeric vector that contains the atmospheric pressure (atm). The default is 1 atm. |
dP |
numeric vector that contains the nominal diameters for the packing material. The Design Guidelines use Jaeger Tripacks 2-in. (50.8 mm) plastic media for the packing material. |
at |
numeric vector that contains the total surface area for the packing material (the default value is 157 m^2/m^3) |
Sc |
numeric vector that contains the critical surface tension for the packing material (the default value is 0.033 kg/s^2) |
cf |
numeric vector that contains the packing factor for the packing material (the default value is 15/ft) |
Temp_unit |
character vector that contains the possible units for the
water temperature [options are |
dP_unit |
character vector that contains the possible units for the nominal diameters for the packing material (inch or mm) |
at_unit |
character vector that contains the possible units for the total surface area for the packing material (ft^2/ft^3 or m^2/m^3) |
Sc_unit |
character vector that contains the possible units for the critical surface tension for the packing material (kg/s^2 or slug/s^2) |
contaminants_table |
integer vector that contains 0, 1 only. 0 represents do not print the Contaminants Table and 1 is for printing the Contaminants Table. |
removal_requirements_table |
integer vector that contains 0, 1 only. 0 represents do not print the Removal Requirements Table and 1 is for printing the Removal Requirements Table. |
critical_contaminant_table |
integer vector that contains 0, 1 only. 0 represents do not print the Critical Contaminant Table and 1 is for printing the Critical Contaminant Table. |
the name of the critical contaminant, molar liquid (water) flow per
unit of stripper cross-sectional area (kg mole/m^2 s), molar gas (air)
flow per unit of stripper cross-sectional area (kg mole/m^2 s), height of
transfer unit (HTU) [m and ft], number of transfer units (NTU), packing
depth (m and feet), and the air to water ratio as a data.table.
If contaminants_table = 1, provide the Contaminants Table. If
removal_requirements_table = 1, provide the Removal Requirements Table. If
critical_contaminant_table = 1, provide the Critical Contaminant Table.
Please Note: Use these results as preliminary estimates only.
Please Note: This is not meant for any actual designs.
Please Note: The calculations assume dry air rather than humid air.
Please refer to the iemisc: Air Stripping By Packed Column Examples vignette for examples
Irucka Embry
Accu Dyne Test: Diversified Enterprises. Critical Surface Tension and Contact Angle with Water for Various Polymers, https://www.accudynetest.com/polytable_03.html.
Design Guide No. 1110-1-3: Air Stripping Engineering and Design Appendix D: Example Air Stripping By Packed Column, Department Of The Army U.S. Army Corps of Engineers, 31 October 2001, pages D-1 - D-18, https://web.archive.org/web/20240217153739/https://www.publications.usace.army.mil/Portals/76/Publications/EngineerDesignGuides/DG_1110-1-3.pdf?ver=2013-08-16-101222-003. Retrieved thanks to the Internet Archive: Wayback Machine
Edgar L Andreas, Design Guide No. 1110-1-3: Handbook of Physical Constants and Functions for Use in Atmospheric Boundary Layer Studies, Department Of The Army U.S. Army Corps of Engineers, October 2005, pages D-1 - D-18, https://apps.dtic.mil/sti/pdfs/ADA440352.pdf.
EnggCyclopedia. Tutorial: air density calculation, 3 January 2022, https://enggcyclopedia.com/2019/04/air-density-calculation/.
Harlan H. Bengtson, PhD, P.E. Continuing Education and Development, Inc., Calculation of Gas Density and Viscosity Course No: H02-008, https://www.scribd.com/document/452763833/Calculation-of-Gas-Density-and-Viscosity-pdf.
PCA Series Packed Column Air Strippers, H2K Technologies, Inc., 2011, page 2, http://www.h2ktech.com/pdf_downloads/PCA_Packed_Column_Air_Strippers.pdf.
Peter J. Mohr, David B. Newell, and Barry N. Taylor. Continuing Education and Development, Inc., CODATA recommended values of the fundamental physical constants: 2014, Reviews Of Modern Physics, Volume 88, July-September 2016, https://web.archive.org/web/20230608140030/https://physics.nist.gov/cuu/pdf/CODATA_JPCRD2016.pdf. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Wikimedia Foundation, Inc. Wikipedia, 27 March 2022, "Air stripping", https://en.wikipedia.org/wiki/Air_stripping.
This function computes the weighted CN (Curve Number) using the user-supplied unit or the default unit of an acre.
angle_force(i, j, k, axis = c("x-axis", "y-axis", "z-axis"))angle_force(i, j, k, axis = c("x-axis", "y-axis", "z-axis"))
i |
numeric vector containing the force component in the x-axis |
j |
numeric vector containing the force component in the y-axis |
k |
numeric vector containing the force component in the z-axis |
axis |
character vector containing axis ("x-axis", "y-axis", or "z-axis") |
the angle theta in degrees
Irucka Embry
Daniel W. Baker and William Haynes, "Engineering Statics: Open & Interactive", January 21, 2025, Page 30, https://engineeringstatics.org/.
# Example 1 Source: Masoud Olia, Ph.D., P.E. and Contributing Authors, "Barron\'s Fundamentals of Engineering Exam", Hauppauge, New York: Barron\'s Educational Series, Inc., 2015, Page 25 # "What is the angle between force F and the x-axis, where F = 30i + 50j - # 20k Newtons?" library(iemisc) Fx <- 30 # 30i Fy <- 50 # 50j Fz <- -20 # -20k angle_force(i = Fx, j = Fy, k = Fz, axis = "x-axis") # Example 2 (Modified from Problem 111) Source: OpenStax: "Calculus" Volume 3: 2.2 Vectors in Three Dimensions [https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions] "A force F of 50N acts on a particle in the direction of the vector OP, where P(3,4,0)." "Find the angle between force F and the positive direction of the x-axis." library(iemisc) Px <- 3 # 3i Py <- 4 # 4j Pz <- 0 # 0k angle_force(i = Px, j = Py, k = Pz, axis = "x-axis")# Example 1 Source: Masoud Olia, Ph.D., P.E. and Contributing Authors, "Barron\'s Fundamentals of Engineering Exam", Hauppauge, New York: Barron\'s Educational Series, Inc., 2015, Page 25 # "What is the angle between force F and the x-axis, where F = 30i + 50j - # 20k Newtons?" library(iemisc) Fx <- 30 # 30i Fy <- 50 # 50j Fz <- -20 # -20k angle_force(i = Fx, j = Fy, k = Fz, axis = "x-axis") # Example 2 (Modified from Problem 111) Source: OpenStax: "Calculus" Volume 3: 2.2 Vectors in Three Dimensions [https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions] "A force F of 50N acts on a particle in the direction of the vector OP, where P(3,4,0)." "Find the angle between force F and the positive direction of the x-axis." library(iemisc) Px <- 3 # 3i Py <- 4 # 4j Pz <- 0 # 0k angle_force(i = Px, j = Py, k = Pz, axis = "x-axis")
This function computes the "approximate estimate of the error" ("percent relative error").
approxerror(pres, prev)approxerror(pres, prev)
pres |
numeric vector that contains the "present approximation" value(s) |
prev |
numeric vector that contains the "previous approximation" value(s) |
Approximate error is expressed as
the "approximate estimate of the error"
the "present approximation"
the "previous approximation"
approximate error, as a percent (%), as a numeric vector.
Irucka Embry
Steven C. Chapra, Applied Numerical Methods with MATLAB for Engineers and Scientists, Second Edition, Boston, Massachusetts: McGraw-Hill, 2008, pages 82-84.
sgm for geometric mean, shm for harmonic mean, cv for
coefficient of variation (CV), rms for root-mean-square (RMS), relerror
for relative error, and ranges for sample range.
library(iemisc) # Example 4.1 from the Reference text (page 84) approxerror(1.5, 1) # answer as a percent (\%)library(iemisc) # Example 4.1 from the Reference text (page 84) approxerror(1.5, 1) # answer as a percent (\%)
Calculates the value of inverse secant for each element of x in
degrees in a manner compatible with GNU Octave/MATLAB.
asecd(x)asecd(x)
x |
A numeric vector containing values in degrees |
The inverse secant of each element of x in degrees.
David Bateman (GNU Octave asecd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
asec if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave asecd asecd (seq(0, 90, by = 10))library(iemisc) # Examples from GNU Octave asecd asecd (seq(0, 90, by = 10))
Calculates the value of inverse sine for each element of x in degrees
in a manner compatible with GNU Octave/MATLAB.
asind(x)asind(x)
x |
A numeric vector containing values in degrees |
The inverse sine of each element of x in degrees.
David Bateman (GNU Octave asind), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
asin if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave asind asind(seq(0, 1, by = 0.1))library(iemisc) # Examples from GNU Octave asind asind(seq(0, 1, by = 0.1))
Calculates the value of the "two-argument arc-tangent" for each element of
(y, x) in degrees in a manner compatible with GNU Octave/MATLAB.
atan2d(y, x)atan2d(y, x)
y |
A numeric vector containing values in degrees |
x |
A numeric vector containing values in degrees |
The "two-argument arc-tangent" of each element of (y, x)
in degrees. Note: "The arc-tangent of two arguments atan2(y, x)
returns the angle between the x-axis and the vector from the origin
to (x, y), i.e., for positive arguments atan2(y, x) == atan(y/x)."
Source: Trig (base).
Rik Wehbring (GNU Octave atan2d), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
atan2 if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave atan2d atan2d (a <- seq(-1, 1, by = 0.1), b <- seq(1, -1, by = -0.1))library(iemisc) # Examples from GNU Octave atan2d atan2d (a <- seq(-1, 1, by = 0.1), b <- seq(1, -1, by = -0.1))
Calculates the value of inverse tangent for each element of x in
degrees in a manner compatible with GNU Octave/MATLAB.
atand(x)atand(x)
x |
A numeric vector containing values in degrees |
The inverse tangent of each element of x in degrees.
David Bateman (GNU Octave atand), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
atan if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave atand atand (seq(0, 90, by = 10))library(iemisc) # Examples from GNU Octave atand atand (seq(0, 90, by = 10))
Computes the bearing, in degrees, using the engineering survey measurement.
Please refer to engr_survey for more information.
bearing_survey( Northing_begin, Easting_begin, Northing_end, Easting_end, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "list") )bearing_survey( Northing_begin, Easting_begin, Northing_end, Easting_end, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "list") )
Northing_begin |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting_begin |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Northing_end |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting_end |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
units |
character vector that contains the system of units (options are
|
location |
character vector that contains the location name ('KY' for Kentucky or 'TN' for Tennessee) [only 1 location at a time] |
output |
character vector that contains basic for the default result
as a numeric vector or list for the result as a |
the bearing as a numeric vector or a list which contains the bearing as a numeric vector and the begin, mid, and end points in decimal degrees (Longitude, Latitude) each as a data.table
Irucka Embry
engr_surveyer for the wrapper function
# Example 1 from project_midpoint function library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 exx <- bearing_survey(Northing_begin = Northing_begin, Easting_begin = Easting_begin, Northing_end = Northing_end, Easting_end = Easting_end, units = "survey_ft", location = "TN", output = "list") exx # Example 2 from engr_survey function install.load::load_package("iemisc", "units", "geosphere") # Modified from engr_survey Example Northing <- c("630817.6396", "502170.6065") Easting <- c("2559599.9201", "1433851.6509") dt1 <- bearing_survey(Northing_begin = Northing[2], Easting_begin = Easting[2], Northing_end = Northing[1], Easting_end = Easting[1], units = "survey_ft", location = "TN", output = "list") dt1 dt1_dist <- set_units(distGeo(c(dt1$begin$Longitude, dt1$begin$Latitude), c(dt1$end$Longitude, dt1$end$Latitude)), m) units(dt1_dist) <- make_units(mi) dt1_dist dt1_dist <- drop_units(dt1_dist) dt1_dist # Test against same coordinates with # https://www.sunearthtools.com/tools/distance.php # 83.51 degrees # 214.194 mi # Relative Error for the distance relerror(dt1_dist, 214.194) # answer as a percent (\%) # Relative Error for the bearing relerror(dt1$bearing, 83.51) # answer as a percent (\%)# Example 1 from project_midpoint function library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 exx <- bearing_survey(Northing_begin = Northing_begin, Easting_begin = Easting_begin, Northing_end = Northing_end, Easting_end = Easting_end, units = "survey_ft", location = "TN", output = "list") exx # Example 2 from engr_survey function install.load::load_package("iemisc", "units", "geosphere") # Modified from engr_survey Example Northing <- c("630817.6396", "502170.6065") Easting <- c("2559599.9201", "1433851.6509") dt1 <- bearing_survey(Northing_begin = Northing[2], Easting_begin = Easting[2], Northing_end = Northing[1], Easting_end = Easting[1], units = "survey_ft", location = "TN", output = "list") dt1 dt1_dist <- set_units(distGeo(c(dt1$begin$Longitude, dt1$begin$Latitude), c(dt1$end$Longitude, dt1$end$Latitude)), m) units(dt1_dist) <- make_units(mi) dt1_dist dt1_dist <- drop_units(dt1_dist) dt1_dist # Test against same coordinates with # https://www.sunearthtools.com/tools/distance.php # 83.51 degrees # 214.194 mi # Relative Error for the distance relerror(dt1_dist, 214.194) # answer as a percent (\%) # Relative Error for the bearing relerror(dt1$bearing, 83.51) # answer as a percent (\%)
Compute the benefit-cost ratio between two alternatives
benefitcost( ic1, n1, ac1, ab1, i1, salvage1, ic2, n2, ac2, ab2, i2, salvage2, option1, option2, table = c("ptable", "rtable", "both") )benefitcost( ic1, n1, ac1, ab1, i1, salvage1, ic2, n2, ac2, ab2, i2, salvage2, option1, option2, table = c("ptable", "rtable", "both") )
ic1 |
numeric vector that contains the initial cost for option 1 |
n1 |
numeric vector that contains the useful life (years) for option 1 |
ac1 |
numeric vector that contains the annual cost [operations & maintenance (O&M)] for option 1 |
ab1 |
numeric vector that contains the annual benefits for option 1 |
i1 |
numeric vector that contains the effective interest rate per period as a percent for option 1 |
salvage1 |
numeric vector that contains the salvage value for option 1 |
ic2 |
numeric vector that contains the initial cost for option 2 |
n2 |
numeric vector that contains the useful life (years) for option 2 |
ac2 |
numeric vector that contains the annual cost [operations & maintenance (O&M)] for option 2 |
ab2 |
numeric vector that contains the annual benefits for option 2 |
i2 |
numeric vector that contains the effective interest rate per period as a percent for option 2 |
salvage2 |
numeric vector that contains the salvage value for option 2 |
option1 |
character vector that contains the option name for option 1 |
option2 |
character vector that contains the option name for option 2 |
table |
character vector that contains the table output format (ptable, rtable, or both) |
Benefit is expressed as
the present equivalent benefit
the annual benefit
the "effective interest rate" per year
the number of years
Cost is expressed as
the present equivalent cost
the present or initial cost
the annual operations & maintenance cost
the salvage value
the "effective interest rate" per year
the number of years
Benefit-Cost ratio is expressed as
the present equivalent cost
the benefit for alternative 1
the benefit for alternative 2
the cost for alternative 1
the cost for alternative 2
data.table with character vectors with the monetary
values having thousands separator in a pretty table (ptable) & message with
the best option, data.frame with numeric vectors without the thousands
separator in regular table (rtable) & a message with the best option, or both
options combined in a list
Irucka Embry
Michael R. Lindeburg, PE, EIT Review Manual, Belmont, California: Professional Publications, Inc., 1996, pages 14-2, 14-4.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 133, 142, 442-443, 452-453.
library(iemisc) # Example from Lindeburg Reference text (page 14-4) benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "rtable") # This is useful for saving the results as the named data.frame rtable rtable <- benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "rtable") rtable # This is useful for saving the results as the named data.frame ptable ptable <- benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "ptable") ptable # This is useful for saving the results as the named list of 2 data.frames # called both both <- benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "both") both # Example 10-8 from the Sullivan Reference text (pages 452-453) project <- benefitcost(ic1 = 750000, n1 = 35, ac1 = 120000, ab1 = 245000, i1 = 9, salvage1 = 0, ic2 = 625000, n2 = 25, ac2 = 110000, ab2 = 230000, i2 = 9, salvage2 = 0, option1 = "Project I", option2 = "Project II", table = "rtable") projectlibrary(iemisc) # Example from Lindeburg Reference text (page 14-4) benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "rtable") # This is useful for saving the results as the named data.frame rtable rtable <- benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "rtable") rtable # This is useful for saving the results as the named data.frame ptable ptable <- benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "ptable") ptable # This is useful for saving the results as the named list of 2 data.frames # called both both <- benefitcost(ic1 = 300000, n1 = 10, ac1 = 45000, ab1 = 150000, i1 = 10, salvage1 = 0, ic2 = 400000, n2 = 10, ac2 = 35000, ab2 = 200000, i2 = 10, salvage2 = 10000, option1 = "A", option2 = "B", table = "both") both # Example 10-8 from the Sullivan Reference text (pages 452-453) project <- benefitcost(ic1 = 750000, n1 = 35, ac1 = 120000, ab1 = 245000, i1 = 9, salvage1 = 0, ic2 = 625000, n2 = 25, ac2 = 110000, ab2 = 230000, i2 = 9, salvage2 = 0, option1 = "Project I", option2 = "Project II", table = "rtable") project
This function computes the composite CN (Curve Number) for connected impervious areas.
c_composite_CN(pervious_CN, impervious)c_composite_CN(pervious_CN, impervious)
pervious_CN |
numeric vector containing the pervious runoff curve number |
impervious |
numeric vector containing the percent imperviousness |
the Composite Runoff Curve Number as a single numeric vector, in the range [0, 100]
Note: Please refer to iemiscdata: Weighted CN Calculations Using the Composite CN vignette in the iemiscdata package
Irucka Embry
United States Department of Agriculture Natural Resources Conservation Service Conservation Engineering Division, "Urban Hydrology for Small Watersheds Technical Release 55 (TR-55)", June 1986, pages 2-11 - 2-16, https://web.archive.org/web/20230810204711/https://directives.sc.egov.usda.gov/OpenNonWebContent.aspx?content=22162.wba [Recovered with the Internet Archive: Wayback Machine]
Takes the Cardinal direction (4-wind compass rose), Intercardinal direction (8-wind compass rose), Secondary intercardinal direction (16-wind compass rose), or Tertiary intercardinal direction (32-wind compass rose) character vector and transforms them into their decimal degrees equivalent (either a single numeric value for the minimal degrees or the character vector representing the numeric degrees range).
cardinal2deg( cardinal, main_winds = c(4, 8, 16, 32), result = c("numeric", "character") )cardinal2deg( cardinal, main_winds = c(4, 8, 16, 32), result = c("numeric", "character") )
cardinal |
character vector that contains the direction |
main_winds |
numeric vector that contains the numbers 4, 8, 16, or 32 representing the winds of the compass rose. |
the degrees as a numeric vector with the minimal degrees value or a character vector with a range of the degrees for the given direction.
Stack Overflow user contributions are "distributed under the terms of CC BY-SA 3.0" "from 2011-04-08 up to but not including 2018-05-02 (UTC)". [Stack Overflow Reference] I have decided to make my adaptions to the Stack Overflow user contributions as CC BY-SA 4.0 thereby enabling me to license my adaptions to the aforementioned code as GPLv3. [Creative Commons References] Stack Overflow user contributions are "distributed under the terms of CC BY-SA 4.0" "on or after 2018-05-02 (UTC)". [Stack Overflow Reference] Thus, my adaptions of the Stack Overflow code can be released as GPLv3. [Creative Commons References]
Irucka Embry
Stack Overflow: Convert from compass direcitions to degrees r answered by user2957945 on Mar 4, 2017 and edited by user2957945 on Mar 10, 2020. See https://stackoverflow.com/questions/42597344/convert-from-compass-direcitions-to-degrees-r.
Stack Overflow: Converting wind direction in angles to text words answered by azdatasci on Sep 26, 2018. See https://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words.
Creative Commons. Weblog Archives, October 8, 2015, "CC BY-SA 4.0 now one-way compatible with GPLv3: The declaration increases interoperability of the commons for games, hardware designs, and more" Posted by mike, https://creativecommons.org/2015/10/08/cc-by-sa-4-0-now-one-way-compatible-with-gplv3/.
Stack Overflow. Help Center, "What is the license for the content I post?", https://stackoverflow.com/help/licensing.
deg2cardinal for the reverse function
# Examples library(iemisc) cardinal <- "North" main_winds1 <- 4 main_winds2 <- 8 main_winds3 <- 16 main_winds4 <- 32 result1 <- "numeric" result2 <- "character" cardinal2deg(cardinal, main_winds = main_winds1, result = result1) cardinal2deg(cardinal, main_winds = main_winds1, result = result2) cardinal2deg(cardinal, main_winds = main_winds2, result = result1) cardinal2deg(cardinal, main_winds = main_winds2, result = result2) cardinal2deg(cardinal, main_winds = main_winds3, result = result1) cardinal2deg(cardinal, main_winds = main_winds3, result = result2) cardinal2deg(cardinal, main_winds = main_winds4, result = result1) cardinal2deg(cardinal, main_winds = main_winds4, result = result2)# Examples library(iemisc) cardinal <- "North" main_winds1 <- 4 main_winds2 <- 8 main_winds3 <- 16 main_winds4 <- 32 result1 <- "numeric" result2 <- "character" cardinal2deg(cardinal, main_winds = main_winds1, result = result1) cardinal2deg(cardinal, main_winds = main_winds1, result = result2) cardinal2deg(cardinal, main_winds = main_winds2, result = result1) cardinal2deg(cardinal, main_winds = main_winds2, result = result2) cardinal2deg(cardinal, main_winds = main_winds3, result = result1) cardinal2deg(cardinal, main_winds = main_winds3, result = result2) cardinal2deg(cardinal, main_winds = main_winds4, result = result1) cardinal2deg(cardinal, main_winds = main_winds4, result = result2)
This function "provides the fast, accurate, and robust computation of the Colebrook-White equation" to determine the "Darcy-Weisbach friction factor F". This method is "more efficient than the solution of the Colebrook equation via the Lambert W-function, or the simple approximations." The solution is accurate to "around machine precision for all R > 3 and for all 0 <= K, i.e. in an interval exceeding all values of physical interest." Reference: Clamond
colebrook(Re, K = NULL)colebrook(Re, K = NULL)
Re |
numeric vector that contains the Reynolds number [dimensionless], which should be >= 2300. Reference: Clamond |
K |
numeric vector that contains the "equivalent sand roughness height sand roughness height (material specific roughness) divided by the hydraulic diameters", if known. If not known, the default value is 0. Reference: Clamond |
Colebrook-White equation is expressed as
Darcy-Weisbach friction factor
Equivalent sand roughness height (material specific roughness) divided by the hydraulic diameters
the Reynolds' number (dimensionless)
F Return a numeric vector containing the Darcy-Weisbach friction factor. Reference: Clamond
Didier Clamond (colebrook MATLAB function), Irucka Embry (colebrook R function)
Steven C. Chapra, Applied Numerical Methods with MATLAB for Engineers and Scientists, Second Edition, Boston, Massachusetts: McGraw-Hill, 2008, pages 157-161.
Didier Clamond, "Efficient resolution of the Colebrook equation", Ind. Eng. Chem. Res., 2009, 48 (7), pages 3665-3671 https://arxiv.org/abs/0810.5564 and https://math.univ-cotedazur.fr/~didierc/DidPublis/ICR_2009.pdf
Re1, Re2, Re3, Re4 for the Reynolds number and
f1, f2, f3, f4, f5, f6, f7,
and f8 for the Darcy friction factor
install.load::load_package("iemisc", "units") # Example 1 (Reference: Clamond) F <- colebrook(c(3e3, 7e5, 1e100), 0.01) F # Example 2 # 'Determine f for air flow through a smooth, thin tube. The parameters are # rho = 1.23 kg/m^3, mu = 1.79 x 10^-5 N * s/m^2, D = 0.005 m, V = 40 m/s # and epsilon = 0.0015 mm.' Reference: Chapra 158 # Determine R (the Reynolds number) first using the following parameters: rho <- 1.23 # kg/m^3 V <- 40 # m/s D <- 0.005 # m mu <- 1.79 * 10^-5 # N * s/m^2 eps <- 0.0015 # mm eps <- set_units(eps, "mm") units(eps) <- make_units(m) Re <- rho * V * D / mu K <- drop_units(eps) / D # with K fr1 <- colebrook(Re, K); fr1 # without K fr2 <- colebrook(Re); fr2 # The solution on Chapra 159 and 160 is 'f = 0.02896781017144' which was # computed using the Newton-Raphson method, Swamee-Jain approximation # equation, and MATLAB's fzero function. # Thus, fm <- 0.02896781017144 # Compute the relative error between fr[1 and 2] (this function) and fm (Chapra). relerror(fr1, fm) relerror(fr2, fm) # compare the relative error with and without Kinstall.load::load_package("iemisc", "units") # Example 1 (Reference: Clamond) F <- colebrook(c(3e3, 7e5, 1e100), 0.01) F # Example 2 # 'Determine f for air flow through a smooth, thin tube. The parameters are # rho = 1.23 kg/m^3, mu = 1.79 x 10^-5 N * s/m^2, D = 0.005 m, V = 40 m/s # and epsilon = 0.0015 mm.' Reference: Chapra 158 # Determine R (the Reynolds number) first using the following parameters: rho <- 1.23 # kg/m^3 V <- 40 # m/s D <- 0.005 # m mu <- 1.79 * 10^-5 # N * s/m^2 eps <- 0.0015 # mm eps <- set_units(eps, "mm") units(eps) <- make_units(m) Re <- rho * V * D / mu K <- drop_units(eps) / D # with K fr1 <- colebrook(Re, K); fr1 # without K fr2 <- colebrook(Re); fr2 # The solution on Chapra 159 and 160 is 'f = 0.02896781017144' which was # computed using the Newton-Raphson method, Swamee-Jain approximation # equation, and MATLAB's fzero function. # Thus, fm <- 0.02896781017144 # Compute the relative error between fr[1 and 2] (this function) and fm (Chapra). relerror(fr1, fm) relerror(fr2, fm) # compare the relative error with and without K
Computes the total interest paid at the end of n periods using compound interest
CompIntCharg( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )CompIntCharg( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
Compound Interest Charged is expressed as
the "principal amount (lent or borrowed)"
the "total interest paid"
the "interest rate per interest period"
the "number of interest periods"
CompIntCharg numeric vector that contains the total interest paid at the end of n periods rounded to 2 decimal places
Irucka Embry
SFPE Handbook of Fire Protection Engineering. 3rd Edition, DiNenno, P. J.; Drysdale, D.; Beyler, C. L.; Walton, W. D., Editor(s), page 5-94, 2002. Chapter 7; Section 5; NFPA HFPE-02. See https://web.archive.org/web/20180127185316/http://fire.nist.gov/bfrlpubs/build02/PDF/b02155.pdf.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 120.
Chinyere Onwubiko, An Introduction to Engineering, Mission, Kansas: Schroff Development Corporation, 1997, pages 205-206.
library(iemisc) # Compound Interest example from SFPE Reference text # Modified example to provide the compounded interest amount paid only CompIntCharg(100, 5, 10, frequency = "annual") # the interest rate is 10\%library(iemisc) # Compound Interest example from SFPE Reference text # Modified example to provide the compounded interest amount paid only CompIntCharg(100, 5, 10, frequency = "annual") # the interest rate is 10\%
Computes the total amount paid at the end of n periods using compound interest
CompIntPaid( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )CompIntPaid( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
Compound Interest is expressed as
the "principal amount (lent or borrowed)"
the "total amount paid back"
the "interest rate per interest period"
the "number of interest periods"
CompIntPaid numeric vector that contains the total amount paid at the end of n periods rounded to 2 decimal places
Irucka Embry
SFPE Handbook of Fire Protection Engineering. 3rd Edition, DiNenno, P. J.; Drysdale, D.; Beyler, C. L.; Walton, W. D., Editor(s), page 5-94, 2002. Chapter 7; Section 5; NFPA HFPE-02. See https://web.archive.org/web/20180127185316/http://fire.nist.gov/bfrlpubs/build02/PDF/b02155.pdf.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 120.
Chinyere Onwubiko, An Introduction to Engineering, Mission, Kansas: Schroff Development Corporation, 1997, pages 205-206.
library(iemisc) # Compound Interest example from SFPE Reference text CompIntPaid(100, 5, 10, frequency = "annual") # the interest rate is 10%library(iemisc) # Compound Interest example from SFPE Reference text CompIntPaid(100, 5, 10, frequency = "annual") # the interest rate is 10%
Calculates the amount of cement, sand, gravel, and water needed for a test batch volume of structural lightweight concrete using the weight method. Note: Currently, this function only works with air-entrained concrete as the author has not found a table to compute the weight of concrete for nonair- entrained concrete.
concr_mix_lightweight_strength( fc, slump_use = NULL, max_size_aggr, FM, sgf_coarse, dry_rod_wt_aggr, absorp_coarse, absorp_fine, entrainment = c("Nonair", "Air"), construction_type = c("Beams and reinforced walls", "Building columns", "Floor slabs"), slump_value = c("Maximum", "Maximum + 1", "Minimum", "Minimum + 1"), exposure = c("Mild", "Moderate", "Extreme"), structure_type = c("Thin section", "Other"), severe_exposure = c("Wet", "Sea water"), trial_batch = c("1 cubic yard", "1 cubic foot", "0.5 cubic foot", "0.2 cubic foot", "All") )concr_mix_lightweight_strength( fc, slump_use = NULL, max_size_aggr, FM, sgf_coarse, dry_rod_wt_aggr, absorp_coarse, absorp_fine, entrainment = c("Nonair", "Air"), construction_type = c("Beams and reinforced walls", "Building columns", "Floor slabs"), slump_value = c("Maximum", "Maximum + 1", "Minimum", "Minimum + 1"), exposure = c("Mild", "Moderate", "Extreme"), structure_type = c("Thin section", "Other"), severe_exposure = c("Wet", "Sea water"), trial_batch = c("1 cubic yard", "1 cubic foot", "0.5 cubic foot", "0.2 cubic foot", "All") )
fc |
numeric vector that contains the concrete compressive strength (psi) |
slump_use |
numeric vector that contains the amount of slump (in) |
max_size_aggr |
numeric vector that contains the maximum aggregate size (in) |
FM |
numeric vector that contains the "Fineness Modulus of sand" (dimensionless) |
sgf_coarse |
numeric vector that contains the "specific gravity factor" of the coarse aggregate (dimensionless) |
dry_rod_wt_aggr |
numeric vector that contains the dry rodded weight of aggregate ["oven-dry loose weight of coarse aggregate"] (lb/ft^3) |
absorp_coarse |
numeric vector that contains the absorption of the coarse aggregate (whole number percent) |
absorp_fine |
numeric vector that contains the absorption of the fine aggregate (whole number percent) |
entrainment |
character vector that contains either Air or Nonair entrainment |
construction_type |
character vector that contains the intended type of construction |
slump_value |
character vector that contains the slump value (Maximum, Maximum + 1, Minimum, or Minimum + 1). It is "+ 1 in. for methods of consolidation other than vibration" |
exposure |
character vector that contains the exposure value (Mild, Moderate, or Extreme) for use with Air entrained concrete mixes |
structure_type |
character vector that contains the severe exposure value ["Thin sections (railings, curbs, sills, ledges, ornamental work) and sections with less than 1 in. cover over steel" or "All other structures"] for use with Air entrained concrete mixes with severe exposure |
severe_exposure |
character vector that contains the severe exposure value ("Structure wet continuously or frequently and exposed to freezing and thawing" or "Structure exposed to sea water or sulfates") for use with Air entrained concrete mixes with severe exposure |
trial_batch |
character vector that contains the volume of the trial batch mix to return (1 cubic yard, 1 cubic foot, 0.5 cubic foot, 0.2 cubic foot, or All) |
the amounts of cement, sand, gravel, and water in lb, rounded to the
hundredth, as a list to make 1 yd^3, 1 ft^3, 0.5 ft^3,
or 0.2 ft^3 of structural lightweight concrete or as a data.table containing
all batch volumes.
Irucka Embry, Hans Werner Borchers for the interp1 and interp2 functions from pracma
r - Error when doing bilinear interpolation with 'interp2 pracma'; any better way for 2D interpolation? - Stack Overflow answered and edited by Zheyuan Li on Dec 8 2016. See https://stackoverflow.com/questions/41032225/error-when-doing-bilinear-interpolation-with-interp2-pracma-any-better-way.
r - data.table 1.10.0 - why does a named column index value not work while a integer column index value works without with = FALSE - Stack Overflow answered and edited by Matt Dowle on Dec 8 2016. See https://stackoverflow.com/questions/41032225/error-when-doing-bilinear-interpolation-with-interp2-pracma-any-better-way.
ACI Committee 211, Standard Practice for Selecting Proportions for Structural Lightweight Concrete (ACI 211.2-98), American Concrete Institute, Farmington Hills, MI, 18 pages. 1998, 211.2-98.
concr_mix_normal_strength for Concrete Mix Design for Normal Strength
(Normal-weight) Concrete
library(iemisc) # Example A from Section 3.2.3 using the 'Weight method (specific gravity # pycnometers)' from ACI Committee 211 # Design a concrete mix for 3500 psi concrete strength, 'floor slab of a # multistory structure subjected to freezing and thawing during # construction', and a maximum size of aggregate = 3/4 in, with Fineness # Modulus of sand = 2.80, 'the oven-dry loose weight of coarse aggregate' = # 47 lb/ft^3 with a specific gravity factor = 1.50, and a absorption of # 11.0\% for the coarse aggregate and 1.0\% for the fine aggregate. concr_mix_lightweight_strength(fc = 3500, max_size_aggr = 3 / 4, FM = 2.80, sgf_coarse = 1.50, dry_rod_wt_aggr = 47, absorp_coarse = 11.0, absorp_fine = 1.0, entrainment = "Air", construction_type = "Floor slabs", slump_value = "Maximum", exposure = "Extreme", structure_type = "Other", severe_exposure = "Wet", trial_batch = "1 cubic foot")library(iemisc) # Example A from Section 3.2.3 using the 'Weight method (specific gravity # pycnometers)' from ACI Committee 211 # Design a concrete mix for 3500 psi concrete strength, 'floor slab of a # multistory structure subjected to freezing and thawing during # construction', and a maximum size of aggregate = 3/4 in, with Fineness # Modulus of sand = 2.80, 'the oven-dry loose weight of coarse aggregate' = # 47 lb/ft^3 with a specific gravity factor = 1.50, and a absorption of # 11.0\% for the coarse aggregate and 1.0\% for the fine aggregate. concr_mix_lightweight_strength(fc = 3500, max_size_aggr = 3 / 4, FM = 2.80, sgf_coarse = 1.50, dry_rod_wt_aggr = 47, absorp_coarse = 11.0, absorp_fine = 1.0, entrainment = "Air", construction_type = "Floor slabs", slump_value = "Maximum", exposure = "Extreme", structure_type = "Other", severe_exposure = "Wet", trial_batch = "1 cubic foot")
Calculates the amount of cement, sand, gravel, and water needed for a test batch volume of normal strength concrete using the volumetric method.
concr_mix_normal_strength( fc, slump_use = NULL, max_size_aggr, FM, dry_rod_wt_aggr, mc_coarse, mc_fine, entrainment = c("Nonair", "Air"), construction_type = c("Reinforced Foundation walls and footings", "Plain footings and caissons", "Slabs, beams and reinforced walls", "Building Columns", "Pavements and slabs", "Heavy mass construction"), slump_value = c("Maximum", "Maximum + 1", "Minimum"), exposure = c("Nonair", "Mild", "Moderate", "Extreme"), trial_batch = c("1 cubic yard", "1 cubic foot", "0.5 cubic foot", "0.2 cubic foot", "All") )concr_mix_normal_strength( fc, slump_use = NULL, max_size_aggr, FM, dry_rod_wt_aggr, mc_coarse, mc_fine, entrainment = c("Nonair", "Air"), construction_type = c("Reinforced Foundation walls and footings", "Plain footings and caissons", "Slabs, beams and reinforced walls", "Building Columns", "Pavements and slabs", "Heavy mass construction"), slump_value = c("Maximum", "Maximum + 1", "Minimum"), exposure = c("Nonair", "Mild", "Moderate", "Extreme"), trial_batch = c("1 cubic yard", "1 cubic foot", "0.5 cubic foot", "0.2 cubic foot", "All") )
fc |
numeric vector that contains the concrete compressive strength (psi) |
slump_use |
numeric vector that contains the amount of slump (in) |
max_size_aggr |
numeric vector that contains the maximum aggregate size (in) |
FM |
numeric vector that contains the "Fineness Modulus of sand" (dimensionless) |
dry_rod_wt_aggr |
numeric vector that contains the dry rodded weight of aggregate (lb/ft^3) |
mc_coarse |
numeric vector that contains the moisture content of the coarse aggregate (whole number percent) |
mc_fine |
numeric vector that contains the moisture content of the fine aggregate (whole number percent) |
entrainment |
character vector that contains either Air or Nonair entrainment |
construction_type |
character vector that contains the intended type of construction |
slump_value |
character vector that contains the slump value (Maximum, Maximum + 1, or Minimum). It is "+ 1 in. for methods of consolidation other than vibration" |
exposure |
character vector that contains the exposure value (Mild, Moderate, or Extreme) for use with Air entrained concrete mixes or Nonair to indicate that it is a Nonair entrained concrete mix |
trial_batch |
character vector that contains the volume of the trial batch mix to return (1 cubic yard, 1 cubic foot, 0.5 cubic foot, 0.2 cubic foot, or All) |
the amounts of cement, sand, gravel, and water in lb, rounded to the
hundredth, as a list to make 1 yd^3, 1 ft^3, 0.5 ft^3,
or 0.2 ft^3 of normal strength concrete or as a data.table containing
all batch volumes.
Irucka Embry, Hans Werner Borchers for the interp1 and interp2 functions from pracma
r - Error when doing bilinear interpolation with 'interp2 pracma'; any better way for 2D interpolation? - Stack Overflow answered and edited by Zheyuan Li on Dec 8 2016. See https://stackoverflow.com/questions/41032225/error-when-doing-bilinear-interpolation-with-interp2-pracma-any-better-way.
r - data.table 1.10.0 - why does a named column index value not work while a integer column index value works without with = FALSE - Stack Overflow answered and edited by Matt Dowle on Dec 8 2016. See https://stackoverflow.com/questions/41032225/error-when-doing-bilinear-interpolation-with-interp2-pracma-any-better-way.
Edward G. Nawy, Reinforced Concrete: A Fundamental Approach, 5th Edition, Upper Saddle River, New Jersey: Pearson Prentice Hall, 2005, pages 23-28.
concr_mix_lightweight_strength for Concrete Mix Design for
Structural Lightweight Concrete
library(iemisc) # 'Example 3.1 Mixture Design of Normal-weight Concrete' from Nawy # (pages 23-28) # Design a concrete mix for 4000 psi concrete strength, beam, and a maximum # size of aggregate = 3/4 in, with Fineness Modulus of sand = 2.6, the dry # rodded weight of aggregate = 100 lb/ft^3^, and a moisture content of 3\% # for the coarse aggregate and 2\% for the fine aggregate. concr_mix_normal_strength(fc = 4000, max_size_aggr = 3 / 4, FM = 2.6, dry_rod_wt_aggr = 100, mc_coarse = 3, mc_fine = 2, entrainment = "Nonair", construction_type = "Reinforced Foundation walls and footings", slump_value = "Maximum", exposure = "Nonair", trial_batch = "1 cubic yard")library(iemisc) # 'Example 3.1 Mixture Design of Normal-weight Concrete' from Nawy # (pages 23-28) # Design a concrete mix for 4000 psi concrete strength, beam, and a maximum # size of aggregate = 3/4 in, with Fineness Modulus of sand = 2.6, the dry # rodded weight of aggregate = 100 lb/ft^3^, and a moisture content of 3\% # for the coarse aggregate and 2\% for the fine aggregate. concr_mix_normal_strength(fc = 4000, max_size_aggr = 3 / 4, FM = 2.6, dry_rod_wt_aggr = 100, mc_coarse = 3, mc_fine = 2, entrainment = "Nonair", construction_type = "Reinforced Foundation walls and footings", slump_value = "Maximum", exposure = "Nonair", trial_batch = "1 cubic yard")
Convert a construction measurement in US Customary Units (foot + inch) with or without a fraction into its equivalent as a decimal
construction_decimal( measurement, decimal = c("traditional", "librecad"), output = c("vector", "table") )construction_decimal( measurement, decimal = c("traditional", "librecad"), output = c("vector", "table") )
measurement |
character vector that contains the construction measurement (foot + inch) |
decimal |
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)]. |
the construction measurement value as a numeric vector
as a decimal or as a table (depends on the output parameters)
the construction measurement value as a character vector as
foot + fraction of an inch or as inch + fraction of an inch (depends on
the parameters)
Irucka Embry
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
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.
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.
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.
LibreCAD v2.2.0 - User Manual - Fundamentals: Units, 7 May 2022, https://librecad-docs-dev.readthedocs.io/en/latest/ref/fundamentals.html#units.
Spike, 1 January 2022, "Foot and Inch to Decimal Format Conversion", https://www.spikevm.com/calculators/fraction-decimal-calculators.php.
construction_measurement for the wrapper function and frac_to_numeric if you only have a measurement in inches
# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 library(iemisc) construction_decimal("2'-0\"", decimal = "traditional", output = "vector") construction_decimal("1'-2 7/16\"", decimal = "librecad", output = "vector") # Example 2 library(iemisc) construction_decimal("0 6", decimal = "traditional", output = "vector") # read as 0 feet 6 inches construction_decimal("0 6", decimal = "librecad", output = "vector") # read as 0 feet 6 inches # Example 3 library(iemisc) tss1 <- "48'-0 1/2\"" tss2 <- "56-9 1/2\"" sum(construction_decimal(tss1, decimal = "traditional", output = "vector"), construction_decimal(tss2, decimal = "traditional", output = "vector")) # See Source 2 and Source 3 # Example 4 library(iemisc) try(construction_decimal(5, decimal = "traditional", output = "vector")) # please see the error message ex_error <- character(0) try(construction_decimal(ex_error, decimal = "traditional", output = "vector")) # please see the error message try(construction_decimal(NA, decimal = "traditional", output = "vector")) # please see the error message try(construction_decimal("feet", decimal = "traditional", output = "vector")) # please see the error message # Example 5 library(iemisc) app1 <- "5' 2\"" app2 <- "6' 3\"" app3 <- construction_decimal(app1, decimal = "traditional", output = "vector") * construction_decimal(app2, decimal = "traditional", output = "vector") app3 # If you want to have the fractional value using 16ths, do the following: construction_fraction(app3, result = "traditional", decimal = "traditional", fraction = 16)# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 library(iemisc) construction_decimal("2'-0\"", decimal = "traditional", output = "vector") construction_decimal("1'-2 7/16\"", decimal = "librecad", output = "vector") # Example 2 library(iemisc) construction_decimal("0 6", decimal = "traditional", output = "vector") # read as 0 feet 6 inches construction_decimal("0 6", decimal = "librecad", output = "vector") # read as 0 feet 6 inches # Example 3 library(iemisc) tss1 <- "48'-0 1/2\"" tss2 <- "56-9 1/2\"" sum(construction_decimal(tss1, decimal = "traditional", output = "vector"), construction_decimal(tss2, decimal = "traditional", output = "vector")) # See Source 2 and Source 3 # Example 4 library(iemisc) try(construction_decimal(5, decimal = "traditional", output = "vector")) # please see the error message ex_error <- character(0) try(construction_decimal(ex_error, decimal = "traditional", output = "vector")) # please see the error message try(construction_decimal(NA, decimal = "traditional", output = "vector")) # please see the error message try(construction_decimal("feet", decimal = "traditional", output = "vector")) # please see the error message # Example 5 library(iemisc) app1 <- "5' 2\"" app2 <- "6' 3\"" app3 <- construction_decimal(app1, decimal = "traditional", output = "vector") * construction_decimal(app2, decimal = "traditional", output = "vector") app3 # If you want to have the fractional value using 16ths, do the following: construction_fraction(app3, result = "traditional", decimal = "traditional", fraction = 16)
Convert a construction measurement in US Customary Units (foot + inch) with or without a fraction into its equivalent as an Engineering value (LibreCAD style)
construction_decimal_eng(measurement)construction_decimal_eng(measurement)
measurement |
character or numeric vector that contains the construction measurement (decimal or foot + inch) |
the engineering construction measurement value as a character vector.
In LibreCAD, a construction measurement of 1'-2 7/16" = 14.43112 (decimal) =
1'-2.43112" (engineering).
Irucka Embry, R. van Twisk (rs_units.cpp code)
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.
LibreCAD, User Manual - Fundamentals: Units: Engineering and Decimal, 7 May 2022, https://librecad-docs-dev.readthedocs.io/en/latest/ref/fundamentals.html#units.
LibreCAD rs_units.cpp code referencing how to calculate the engineering units.
construction_measurement for the wrapper function
# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples library(iemisc) librecad1a <- "1 ft 2 7/16\"" construction_decimal_eng(librecad1a) librecad4a <- 14.43112 construction_decimal_eng(librecad4a) librecad5a <- 14.4375 construction_decimal_eng(librecad5a) librecad6a <- 17.71354 construction_decimal_eng(librecad6a) librecad7a <- 86.000000 construction_decimal_eng(librecad7a) checkst <- 14.43112 construction_decimal_eng(checkst) construction_fraction(checkst, decimal = "librecad", result = "traditional", fraction = 16)# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples library(iemisc) librecad1a <- "1 ft 2 7/16\"" construction_decimal_eng(librecad1a) librecad4a <- 14.43112 construction_decimal_eng(librecad4a) librecad5a <- 14.4375 construction_decimal_eng(librecad5a) librecad6a <- 17.71354 construction_decimal_eng(librecad6a) librecad7a <- 86.000000 construction_decimal_eng(librecad7a) checkst <- 14.43112 construction_decimal_eng(checkst) construction_fraction(checkst, decimal = "librecad", result = "traditional", fraction = 16)
Convert a construction measurement in US Customary Units as a decimal into its nearest equivalent as foot + inch with or without a fraction
construction_fraction( measurement, decimal = c("traditional", "librecad"), result = c("traditional", "inch"), fraction = c(0, 2, 4, 8, 16, 32, 64, 100, 128, 256) )construction_fraction( measurement, decimal = c("traditional", "librecad"), result = c("traditional", "inch"), fraction = c(0, 2, 4, 8, 16, 32, 64, 100, 128, 256) )
measurement |
numeric vector that contains the construction measurement as a decimal |
decimal |
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.4375 = 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. |
result |
character vector that contains the resulting fraction type (options are traditional (ex. 1.203125 = 1 ft 2 7/16 in) & inch (ex. 14.4375 = 14 7/16 in)). This is the same as fractional (fractional inch) in LibreCAD. |
fraction |
numeric vector that contains the fractional part to return. The options are 0, 2, 4, 8, 16, 32, 64, 100, 128, or 256. |
the construction measurement value as a character vector as
foot + fraction of an inch or as inch + fraction of an inch (depends on
the parameters)
Irucka Embry
Spike, 7 May 2022, "How to Convert Feet in Decimal Format to Foot, Inch and Fraction Values", https://www.spikevm.com/construction-math/convert-decimal-fraction.php.
myCarpentry, 7 May 2022, "Online Fraction Calculator", https://www.mycarpentry.com/online-fraction-calculator.html.
LibreCAD, User Manual - Fundamentals: Units: Architectural and Decimal, 7 May 2022, https://librecad-docs-dev.readthedocs.io/en/latest/ref/fundamentals.html#units.
Inch Calculator. Inch Fraction Calculator – Convert Decimal to Inches, 9 May 2022, https://www.inchcalculator.com/inch-fraction-calculator/.
construction_measurement for the wrapper function
# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples library(iemisc) # Example 1 from the Spike Reference check1 <- 18.649 # decimal feet construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 16) # Reverse the calculation to check out the absolute error check2 <- construction_decimal(construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 16), decimal = "traditional", output = "vector") fracture::fracture(check2 - check1) # difference in inches # by approximate error approxerror(check2, check1) # answer as a percent (\%) # check all other fraction levels construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 0) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 2) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 4) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 8) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 32) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 64) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 100) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 128) # Example 2 library(iemisc) import::from(fpCompare, "%==%") x1 <- construction_fraction(1.203125, decimal = "traditional", result = "traditional", fraction = 16) x2 <- construction_fraction(14.4375, decimal = "librecad", result = "inch", fraction = 16) x3 <- construction_fraction(14.4375, decimal = "librecad", result = "traditional", fraction = 16) x4 <- construction_fraction(14.43112, decimal = "librecad", result = "traditional", fraction = 16) x5 <- construction_fraction(14.43112, decimal = "librecad", result = "inch", fraction = 16) ex1 <- frac_to_numeric(x2) ex2 <- construction_decimal(x1, decimal = "librecad", output = "vector") ex3 <- construction_decimal(x3, decimal = "librecad", output = "vector") ex4 <- construction_decimal(x4, decimal = "librecad", output = "vector") ex5 <- frac_to_numeric(x5) # check if ex1, ex2, ex3, ex4, and ex5 are equivalent ex1 %==% ex2 ex1 %==% ex3 ex1 %==% ex4 ex1 %==% ex5 ex2 %==% ex3 ex2 %==% ex4 ex2 %==% ex5 ex3 %==% ex4 ex3 %==% ex5 ex4 %==% ex5 # Example 3 (from the Inch Calculator Reference) library(iemisc) construction_fraction(2.695, decimal = "librecad", result = "traditional", fraction = 16) construction_fraction(2.695, decimal = "librecad", result = "inch", fraction = 16) # Example 4 library(iemisc) construction_fraction(17.71354, decimal = "traditional", result = "traditional", fraction = 16) construction_fraction(17.71354, decimal = "traditional", result = "inch", fraction = 16)# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples library(iemisc) # Example 1 from the Spike Reference check1 <- 18.649 # decimal feet construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 16) # Reverse the calculation to check out the absolute error check2 <- construction_decimal(construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 16), decimal = "traditional", output = "vector") fracture::fracture(check2 - check1) # difference in inches # by approximate error approxerror(check2, check1) # answer as a percent (\%) # check all other fraction levels construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 0) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 2) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 4) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 8) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 32) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 64) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 100) construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 128) # Example 2 library(iemisc) import::from(fpCompare, "%==%") x1 <- construction_fraction(1.203125, decimal = "traditional", result = "traditional", fraction = 16) x2 <- construction_fraction(14.4375, decimal = "librecad", result = "inch", fraction = 16) x3 <- construction_fraction(14.4375, decimal = "librecad", result = "traditional", fraction = 16) x4 <- construction_fraction(14.43112, decimal = "librecad", result = "traditional", fraction = 16) x5 <- construction_fraction(14.43112, decimal = "librecad", result = "inch", fraction = 16) ex1 <- frac_to_numeric(x2) ex2 <- construction_decimal(x1, decimal = "librecad", output = "vector") ex3 <- construction_decimal(x3, decimal = "librecad", output = "vector") ex4 <- construction_decimal(x4, decimal = "librecad", output = "vector") ex5 <- frac_to_numeric(x5) # check if ex1, ex2, ex3, ex4, and ex5 are equivalent ex1 %==% ex2 ex1 %==% ex3 ex1 %==% ex4 ex1 %==% ex5 ex2 %==% ex3 ex2 %==% ex4 ex2 %==% ex5 ex3 %==% ex4 ex3 %==% ex5 ex4 %==% ex5 # Example 3 (from the Inch Calculator Reference) library(iemisc) construction_fraction(2.695, decimal = "librecad", result = "traditional", fraction = 16) construction_fraction(2.695, decimal = "librecad", result = "inch", fraction = 16) # Example 4 library(iemisc) construction_fraction(17.71354, decimal = "traditional", result = "traditional", fraction = 16) construction_fraction(17.71354, decimal = "traditional", result = "inch", fraction = 16)
Wrapper function to the construction_fraction, frac_to_numeric, construction_decimal, and construction_decimal_eng functions.
construction_measurement( measurement, decimal = c("traditional", "librecad"), result = c("traditional", "inch"), fraction = c(0, 2, 4, 8, 16, 32, 64, 100, 128, 256), output = c("vector", "table"), final = c("fraction", "decimal", "decimal_eng") )construction_measurement( measurement, decimal = c("traditional", "librecad"), result = c("traditional", "inch"), fraction = c(0, 2, 4, 8, 16, 32, 64, 100, 128, 256), output = c("vector", "table"), final = c("fraction", "decimal", "decimal_eng") )
measurement |
character or numeric vector that contains the construction measurement (decimal or foot + inch) OR the fraction or mixed number (can also include text, ex. inch, inches, etc. that will be removed from the vector) |
decimal |
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. |
result |
character vector that contains the resulting fraction type (options are traditional (ex. 1.203125 = 1 ft 2 7/16 in) & inch (ex. 14.4375 = 14 7/16 in)). This is the same as fractional (fractional inch) in LibreCAD. |
fraction |
numeric vector that contains the fractional part to return. The options are 0, 2, 4, 8, 16, 32, 64, 100, 128, or 256. |
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)]. |
final |
character vector that contains the format of the numeric vector. The options are fraction (construction_fraction), decimal (frac_to_numeric or construction_decimal), or decimal_eng (for the construction_decimal_eng) |
the construction measurement value as a character vector as
foot + fraction of an inch or as inch + fraction of an inch (depends on
the parameters); a decimal; the construction measurement value as a numeric
vector as a decimal or as a table (depends on the output parameters);
OR the engineering construction measurement value as a character vector.
In LibreCAD, a construction measurement of 1'-2 7/16" = 14.43112 (decimal) =
1'-2.43112" (engineering).
construction_fraction for Construction Fraction, frac_to_numeric
for Fraction (or Mixed number) to a Decimal (Numeric Vector), construction_decimal
for Construction Decimal, and construction_decimal_eng for Construction Decimal Engineering (LibreCAD Style).
# Examples library(iemisc) # Example 1 from Example 2 in construction_fraction check1 <- 14.43112 # decimal feet construction_measurement(check1, decimal = "traditional", result = "traditional", fraction = 16, final = "fraction") construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 16) # Example 2 library(iemisc) construction_measurement(17.71354, decimal = "traditional", result = "traditional", fraction = 16, final = "fraction") construction_measurement(17.71354, decimal = "traditional", result = "inch", fraction = 16, final = "fraction") # Example 3 library(iemisc) # 0.2356 inch construction_measurement(0.2356, decimal = "traditional", result = "traditional", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "traditional", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "inch", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "inch", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "traditional", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "traditional", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "inch", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "inch", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "traditional", fraction = 256, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "traditional", fraction = 256, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "inch", fraction = 256, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "inch", fraction = 256, final = "fraction") # Example 4 from Example 6 in frac_to_numeric library(iemisc) xxift <- "49 ft 7 5/8 in" construction_measurement(xxift, decimal = "traditional", output = "vector", final = "decimal") %==% construction_decimal(xxift, decimal = "traditional", output = "vector") construction_measurement(xxift, decimal = "traditional", output = "vector", final = "decimal") construction_decimal(xxift, decimal = "traditional", output = "vector") # Example 5 from Example 7 -- Reference 2 in frac_to_numeric install.load::load_package("iemisc", "fpCompare") truss_marks <- "19 3/16 inches" construction_measurement(truss_marks, final = "decimal") %==% frac_to_numeric(truss_marks) construction_measurement(truss_marks, final = "decimal") frac_to_numeric(truss_marks) # Example 6 from Example 2 in construction_decimal install.load::load_package("iemisc", "fpCompare") tos <- "0 6" construction_measurement(tos, decimal = "traditional", output = "vector", final = "decimal") %==% construction_decimal("0 6", decimal = "traditional", output = "vector") construction_measurement(tos, decimal = "traditional", output = "vector", final = "decimal") construction_decimal("0 6", decimal = "traditional", output = "vector") # Example 7 from Example 3 in construction_decimal install.load::load_package("iemisc", "fpCompare") tss2 <- "56-9 1/2\"" construction_measurement(tss2, decimal = "traditional", output = "vector", final = "decimal") %==% construction_decimal(tss2, decimal = "traditional", output = "vector") construction_measurement(tss2, decimal = "traditional", output = "vector", final = "decimal") construction_decimal(tss2, decimal = "traditional", output = "vector") # Example 8 from Example 5 in frac_to_numeric install.load::load_package("iemisc", "fpCompare") pix <- "270/11" construction_measurement(pix, final = "decimal") %==% frac_to_numeric(pix) construction_measurement(pix, final = "decimal") frac_to_numeric(pix) # Example 9 # There are 315 plates with a length of 12 7/8 inch and a width of 4 1/2 inch. # What is the total length, width, and area of the plates? install.load::load_package("iemisc", "units") np <- 315 # total length (in) ll <- "12 7/8" # inch np_ll <- np * construction_measurement(ll, final = "decimal") np_ll # total width (in) ww <- "4 1/2" # inch np_ww <- np * construction_measurement(ww, final = "decimal") np_ww # total area (in^2) ta <- np_ll * np_ww ta # total area (ft^2) ta <- np_ll * np_ww ta ta_ft2 <- set_units(ta, inch^2) units(ta_ft2) <- make_units(feet^2)# Examples library(iemisc) # Example 1 from Example 2 in construction_fraction check1 <- 14.43112 # decimal feet construction_measurement(check1, decimal = "traditional", result = "traditional", fraction = 16, final = "fraction") construction_fraction(check1, decimal = "traditional", result = "traditional", fraction = 16) # Example 2 library(iemisc) construction_measurement(17.71354, decimal = "traditional", result = "traditional", fraction = 16, final = "fraction") construction_measurement(17.71354, decimal = "traditional", result = "inch", fraction = 16, final = "fraction") # Example 3 library(iemisc) # 0.2356 inch construction_measurement(0.2356, decimal = "traditional", result = "traditional", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "traditional", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "inch", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "inch", fraction = 16, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "traditional", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "traditional", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "inch", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "inch", fraction = 128, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "traditional", fraction = 256, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "traditional", fraction = 256, final = "fraction") construction_measurement(0.2356, decimal = "traditional", result = "inch", fraction = 256, final = "fraction") construction_measurement(0.2356, decimal = "librecad", result = "inch", fraction = 256, final = "fraction") # Example 4 from Example 6 in frac_to_numeric library(iemisc) xxift <- "49 ft 7 5/8 in" construction_measurement(xxift, decimal = "traditional", output = "vector", final = "decimal") %==% construction_decimal(xxift, decimal = "traditional", output = "vector") construction_measurement(xxift, decimal = "traditional", output = "vector", final = "decimal") construction_decimal(xxift, decimal = "traditional", output = "vector") # Example 5 from Example 7 -- Reference 2 in frac_to_numeric install.load::load_package("iemisc", "fpCompare") truss_marks <- "19 3/16 inches" construction_measurement(truss_marks, final = "decimal") %==% frac_to_numeric(truss_marks) construction_measurement(truss_marks, final = "decimal") frac_to_numeric(truss_marks) # Example 6 from Example 2 in construction_decimal install.load::load_package("iemisc", "fpCompare") tos <- "0 6" construction_measurement(tos, decimal = "traditional", output = "vector", final = "decimal") %==% construction_decimal("0 6", decimal = "traditional", output = "vector") construction_measurement(tos, decimal = "traditional", output = "vector", final = "decimal") construction_decimal("0 6", decimal = "traditional", output = "vector") # Example 7 from Example 3 in construction_decimal install.load::load_package("iemisc", "fpCompare") tss2 <- "56-9 1/2\"" construction_measurement(tss2, decimal = "traditional", output = "vector", final = "decimal") %==% construction_decimal(tss2, decimal = "traditional", output = "vector") construction_measurement(tss2, decimal = "traditional", output = "vector", final = "decimal") construction_decimal(tss2, decimal = "traditional", output = "vector") # Example 8 from Example 5 in frac_to_numeric install.load::load_package("iemisc", "fpCompare") pix <- "270/11" construction_measurement(pix, final = "decimal") %==% frac_to_numeric(pix) construction_measurement(pix, final = "decimal") frac_to_numeric(pix) # Example 9 # There are 315 plates with a length of 12 7/8 inch and a width of 4 1/2 inch. # What is the total length, width, and area of the plates? install.load::load_package("iemisc", "units") np <- 315 # total length (in) ll <- "12 7/8" # inch np_ll <- np * construction_measurement(ll, final = "decimal") np_ll # total width (in) ww <- "4 1/2" # inch np_ww <- np * construction_measurement(ww, final = "decimal") np_ww # total area (in^2) ta <- np_ll * np_ww ta # total area (ft^2) ta <- np_ll * np_ww ta ta_ft2 <- set_units(ta, inch^2) units(ta_ft2) <- make_units(feet^2)
Calculates the value of cosine for each element of x in degrees in a
manner compatible with GNU Octave/MATLAB. Zero is returned for any 'elements
where (x - 90) / 180 is an integer.' Reference: Eaton.
cosd(x)cosd(x)
x |
A numeric vector containing values in degrees |
The cosine of each element of x in degrees. Zero for any
'elements where (x - 90) / 180 is an integer.'
David Bateman (GNU Octave cosd), Irucka Embry
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.
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.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 553.
Wikimedia Foundation, Inc. Wikipedia, 24 February 2019, "Radian", https://en.wikipedia.org/wiki/Radian.
cos if you have a radian (rad) angle value
library(iemisc) # Example from GNU Octave cosd cosd(seq(0, 80, by = 10)) # See Source 1 and Source 2 library(iemisc) try(cosd("90"))library(iemisc) # Example from GNU Octave cosd cosd(seq(0, 80, by = 10)) # See Source 1 and Source 2 library(iemisc) try(cosd("90"))
Calculates the value of inverse secant for each element of x in
degrees in a manner compatible with GNU Octave/MATLAB.
cotd(x)cotd(x)
x |
A numeric vector containing values in degrees |
The inverse secant of each element of x in degrees.
David Bateman (GNU Octave cotd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
library(iemisc) # Examples from GNU Octave cotd cotd (seq(0, 80, by = 10)) cotd (c(0, 180, 360)) cotd (c(90, 270))library(iemisc) # Examples from GNU Octave cotd cotd (seq(0, 80, by = 10)) cotd (c(0, 180, 360)) cotd (c(90, 270))
Calculates the value of cosecant for each element of x in degrees in a
manner compatible with GNU Octave/MATLAB.
cscd(x)cscd(x)
x |
A numeric vector containing values in degrees |
The cosecant of each element of x in degrees.
David Bateman (GNU Octave cscd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 554.
asin if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave cscd cscd (seq(0, 90, by = 10)) cscd (c(0, 180, 360)) cscd (c(90, 270))library(iemisc) # Examples from GNU Octave cscd cscd (seq(0, 90, by = 10)) cscd (c(0, 180, 360)) cscd (c(90, 270))
This function computes the sample coefficient of variation (CV).
cv(x, na.rm = FALSE)cv(x, na.rm = FALSE)
x |
numeric vector, matrix, data.frame, or data.table that contains the sample data points. |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
CV is expressed as
the sample standard deviation
the sample arithmetic mean
coefficient of variation (CV), as a percent (%), as an R object: a numeric
vector or a named numeric vector if using a named object (matrix,
data.frame, or data.table). The default choice is that any NA values
will be kept (na.rm = FALSE). This can be changed by specifying na.rm = TRUE,
such as cv(x, na.rm = TRUE).
Irucka Embry
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.
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.
Masoud Olia, Ph.D., P.E. and Contributing Authors, Barron's FE (Fundamentals of Engineering Exam), 3rd Edition, Hauppauge, New York: Barron's Educational Series, Inc., 2015, page 84.
Irwin R. Miller, John E. Freund, and Richard Johnson, Probability and Statistics for Engineers, Fourth Edition, Englewood Cliffs, New Jersey: Prentice-Hall, Inc., 1990, pages 25, 38.
sgm for geometric mean, shm for harmonic mean, rms
for root-mean-square (RMS), relerror for relative error, approxerror for
approximate error, and ranges for sample range.
# Example 2.60 from Miller (page 38) library(iemisc) x <- c(14, 12, 21, 28, 30, 63, 29, 63, 55, 19, 20) # suspended solids in parts per million (ppm) cv(x) # using a matrix of the numeric vector x mat1 <- matrix(data = x, nrow = length(x), ncol = 1, byrow = FALSE, dimnames = list(c(rep("", length(x))), "Samples")) cv(mat1) # using a data.frame of the numeric vector x df <- data.frame(x) cv(df) # using a data.table of the numeric vector x library(data.table) dt <- data.table(x) cv(dt) # modified Example 2.60 from Miller (page 38) xx <- c(14, 12, 21, 28, 30, 63, 29, 63, 55, 19, 20, NA) # suspended solids in parts per million (ppm) cv(xx) # na.rm = FALSE is the default cv(xx, na.rm = TRUE) # See Source 1 and Source 2 # Example 3 # Please see the error messages library(iemisc) try(cv(0)) try(cv(1)) try(cv(1003.23)) # Example 4 - from the archived cvcqv README xu <- c(0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4, 4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9) results2 <- cv(xu) results2# Example 2.60 from Miller (page 38) library(iemisc) x <- c(14, 12, 21, 28, 30, 63, 29, 63, 55, 19, 20) # suspended solids in parts per million (ppm) cv(x) # using a matrix of the numeric vector x mat1 <- matrix(data = x, nrow = length(x), ncol = 1, byrow = FALSE, dimnames = list(c(rep("", length(x))), "Samples")) cv(mat1) # using a data.frame of the numeric vector x df <- data.frame(x) cv(df) # using a data.table of the numeric vector x library(data.table) dt <- data.table(x) cv(dt) # modified Example 2.60 from Miller (page 38) xx <- c(14, 12, 21, 28, 30, 63, 29, 63, 55, 19, 20, NA) # suspended solids in parts per million (ppm) cv(xx) # na.rm = FALSE is the default cv(xx, na.rm = TRUE) # See Source 1 and Source 2 # Example 3 # Please see the error messages library(iemisc) try(cv(0)) try(cv(1)) try(cv(1003.23)) # Example 4 - from the archived cvcqv README xu <- c(0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4, 4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9) results2 <- cv(xu) results2
Takes degrees values (as numeric vector or character vector coercible to a numeric vector) and transforms them into their respective Cardinal direction (4-wind compass rose), Intercardinal direction (8-wind compass rose), Secondary intercardinal direction (16-wind compass rose), or Tertiary intercardinal direction (32-wind compass rose) character vectors.
deg2cardinal(degrees, main_winds = c(4, 8, 16, 32))deg2cardinal(degrees, main_winds = c(4, 8, 16, 32))
degrees |
numeric vector (or character vector coercible to a numeric vector) that contains the degrees value. |
main_winds |
numeric vector that contains the numbers 4, 8, 16, or 32 representing the winds of the compass rose. |
the cardinal or intercardinal direction for the given compass rose
Stack Overflow user contributions are "distributed under the terms of CC BY-SA 3.0" "from 2011-04-08 up to but not including 2018-05-02 (UTC)". [Stack Overflow Reference] I have decided to make my adaptions to the Stack Overflow user contributions as CC BY-SA 4.0 thereby enabling me to license my adaptions to the aforementioned code as GPLv3. [Creative Commons References] Stack Overflow user contributions are "distributed under the terms of CC BY-SA 4.0" "on or after 2018-05-02 (UTC)". [Stack Overflow Reference] Thus, my adaptions of the Stack Overflow code can be released as GPLv3. [Creative Commons References]
Irucka Embry
Stack Overflow: Convert from compass direcitions to degrees r answered by user2957945 on Mar 4, 2017 and edited by user2957945 on Mar 10, 2020. See https://stackoverflow.com/questions/42597344/convert-from-compass-direcitions-to-degrees-r.
Stack Overflow: Converting wind direction in angles to text words answered by azdatasci on Sep 26, 2018. See https://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words.
Creative Commons. Weblog Archives, October 8, 2015, "CC BY-SA 4.0 now one-way compatible with GPLv3: The declaration increases interoperability of the commons for games, hardware designs, and more" Posted by mike, https://creativecommons.org/2015/10/08/cc-by-sa-4-0-now-one-way-compatible-with-gplv3/.
Stack Overflow. Help Center, "What is the license for the content I post?", https://stackoverflow.com/help/licensing.
Wikimedia Foundation, Inc. Wikipedia, 16 September 2025, "Points of the compass", https://en.wikipedia.org/wiki/Points_of_the_compass.
cardinal2deg for the reverse function
# Example 1 from bearing_survey library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 ne <- bearing_survey(Northing_begin, Easting_begin, Northing_end, Easting_end, units = "survey_ft", location = "TN", output = "basic") ne deg2cardinal(ne, main_winds = 4) deg2cardinal(ne, main_winds = 8) deg2cardinal(ne, main_winds = 16) deg2cardinal(ne, main_winds = 32) # Examples 2 install.load::load_package("iemisc", "sp") deg2cardinal(50.62, main_winds = 8) deg2cardinal(c(23, 57), main_winds = 16) deg2cardinal(c(80.62, 123), main_winds = 8) deg2cardinal(201.07628, main_winds = 32) deg2cardinal("201.07628", main_winds = 16) deg2cardinal(340.9237, main_winds = 16) deg2cardinal(320.9237, main_winds = 8) deg2cardinal(as.numeric(char2dms("36d22'6.43923\"N")), main_winds = 4) deg2cardinal(as.numeric(char2dms("36d22'6.43923\"N")), main_winds = 32) deg2cardinal(as.numeric(char2dms("82d10'46.87679\"W")), main_winds = 8) as.numeric(char2dms("82d10'46.87679\"W")) # Notice the sign of the degrees deg2cardinal(as.numeric(char2dms("82d10'46.87679\"W")), main_winds = 32)# Example 1 from bearing_survey library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 ne <- bearing_survey(Northing_begin, Easting_begin, Northing_end, Easting_end, units = "survey_ft", location = "TN", output = "basic") ne deg2cardinal(ne, main_winds = 4) deg2cardinal(ne, main_winds = 8) deg2cardinal(ne, main_winds = 16) deg2cardinal(ne, main_winds = 32) # Examples 2 install.load::load_package("iemisc", "sp") deg2cardinal(50.62, main_winds = 8) deg2cardinal(c(23, 57), main_winds = 16) deg2cardinal(c(80.62, 123), main_winds = 8) deg2cardinal(201.07628, main_winds = 32) deg2cardinal("201.07628", main_winds = 16) deg2cardinal(340.9237, main_winds = 16) deg2cardinal(320.9237, main_winds = 8) deg2cardinal(as.numeric(char2dms("36d22'6.43923\"N")), main_winds = 4) deg2cardinal(as.numeric(char2dms("36d22'6.43923\"N")), main_winds = 32) deg2cardinal(as.numeric(char2dms("82d10'46.87679\"W")), main_winds = 8) as.numeric(char2dms("82d10'46.87679\"W")) # Notice the sign of the degrees deg2cardinal(as.numeric(char2dms("82d10'46.87679\"W")), main_winds = 32)
This function solves for the density of water using only the temperature of the water in either units of degrees Celsius, degrees Fahrenheit, or Kelvin.
density_water( Temp, units = c("SI", "Eng", "Absolute"), Eng_units = c("slug/ft^3", "lbm/ft^3") )density_water( Temp, units = c("SI", "Eng", "Absolute"), Eng_units = c("slug/ft^3", "lbm/ft^3") )
Temp |
numeric vector that contains the temperature (degrees Celsius, degrees Fahrenheit, or Kelvin) |
units |
character vector that contains the system of units [options are
|
Eng_units |
character vector that contains the unit for the density of water [options are slug/ft^3 or lbm/ft^3] |
The simplified equation is expressed as
where
where
where
where
with
Water Density (mass divided by volume) [kg/m^3, slug/ft^3, or lbm/ft^3]
Water Density at the critical point, kg/m^3
the water temperature, Kelvin
the critical water temperature, Kelvin
the density as a numeric vector. The units are not returned.
Note: 1 lbf = 1 slug * 1 ft/sec^2, thus 1 slug = 1 lbf * sec^2 / 1 ft (Reference 2)
Thus, lbm/ft^3 = lbf*s^2/ft/ft^3
Irucka Embry
IAPWS SR1-86 (1992). "Revised Supplementary Release on Saturation Properties of Ordinary Water Substance". September 1992, https://www.iapws.org/relguide/Supp-sat.html
# Example 1 (Compare to reference standard in Reference paper) library(iemisc) 273.16 # K 373.1243 # K 647.096 # K Temp <- c(273.16, 373.1243, 647.096) round::round_r3(density_water(Temp, units = "Absolute"), d = 3) # Reference standard 999.789 # kg/m^3 958.365 # kg/m^3 322 # kg/m^3 # Example 2 - Example from the hydraulics package library(iemisc) rho <- hydraulics::dens(T = 25, units = "SI"); rho rho2 <- density_water(Temp = 25, units = "SI"); rho2 # Example 3 - compare with densityH2Ov from aiRthermo install.load::load_package("iemisc", "units") Temp <- 180 # create a numeric vector with the units of degrees Celsius T_C <- set_units(Temp, "degree_C") T_C # create a numeric vector to convert from degrees Celsius to Kelvin T_K <- T_C T_K # create a numeric vector with the units of Kelvin units(T_K) <- make_units(K) pre <- aiRthermo::saturation_pressure_H2O(drop_units(T_K)) pre rho_h2o <- aiRthermo::densityH2Ov(pre, drop_units(T_K), consts = aiRthermo::export_constants()); rho_h2o # Should not be the same as aiRthermo deals with water vapor rather than # saturated liquid water density_water(Temp = drop_units(T_K), units = "Absolute")# Example 1 (Compare to reference standard in Reference paper) library(iemisc) 273.16 # K 373.1243 # K 647.096 # K Temp <- c(273.16, 373.1243, 647.096) round::round_r3(density_water(Temp, units = "Absolute"), d = 3) # Reference standard 999.789 # kg/m^3 958.365 # kg/m^3 322 # kg/m^3 # Example 2 - Example from the hydraulics package library(iemisc) rho <- hydraulics::dens(T = 25, units = "SI"); rho rho2 <- density_water(Temp = 25, units = "SI"); rho2 # Example 3 - compare with densityH2Ov from aiRthermo install.load::load_package("iemisc", "units") Temp <- 180 # create a numeric vector with the units of degrees Celsius T_C <- set_units(Temp, "degree_C") T_C # create a numeric vector to convert from degrees Celsius to Kelvin T_K <- T_C T_K # create a numeric vector with the units of Kelvin units(T_K) <- make_units(K) pre <- aiRthermo::saturation_pressure_H2O(drop_units(T_K)) pre rho_h2o <- aiRthermo::densityH2Ov(pre, drop_units(T_K), consts = aiRthermo::export_constants()); rho_h2o # Should not be the same as aiRthermo deals with water vapor rather than # saturated liquid water density_water(Temp = drop_units(T_K), units = "Absolute")
This function computes the discount price using the original and sales prices.
discount(original_price, sales_price)discount(original_price, sales_price)
original_price |
numeric vector containing the original price of the item. |
sales_price |
numeric vector containing the sales price of the item. |
a numeric vector with the discount amount.
Irucka Embry
Mathspar Tutorials. "Discount Calculator (With Steps) — Find the Discount (percent) or Price Before or After Discount", https://mathspar.com/discount-calculator/.
final_price and the discount_percent
# Examples library(iemisc) discount(2.24, 2.00) original_price <- 12345.98 sales_price <- 67.32 discount(original_price, sales_price)# Examples library(iemisc) discount(2.24, 2.00) original_price <- 12345.98 sales_price <- 67.32 discount(original_price, sales_price)
This function computes the discount percent using the original and sales prices.
discount_percent(original_price, sales_price)discount_percent(original_price, sales_price)
original_price |
numeric vector containing the original price of the item. |
sales_price |
numeric vector containing the sales price of the item. |
a numeric vector with the discount amount.
Irucka Embry
Mathspar Tutorials. "Discount Calculator (With Steps) — Find the Discount (percent) or Price Before or After Discount", https://mathspar.com/discount-calculator/.
final_price and the discount
# Examples library(iemisc) discount_percent(2.24, 2.00) original_price <- 12345.98 sales_price <- 67.32 discount_percent(original_price, sales_price)# Examples library(iemisc) discount_percent(2.24, 2.00) original_price <- 12345.98 sales_price <- 67.32 discount_percent(original_price, sales_price)
Computes the daily amount of water to drink based on a Human Being's mass (grams or kilograms) or weight (pound force). Although technically speaking this function uses the lb mass (lbm) unit in the conversion calculations, it is "standing in" for the scale weight as lb force (lbf). For example, a scale weight of 190 lbs (lbf) would have a mass of 190 and a mass_unit of lb mass for use in this function. Please refer to the 3 references dealing with mass and weight and remember that Weight = Mass x the Earth's gravitational effect.
drink_water_daily( mass, mass_unit = c("lb mass", "kg", "g"), water_unit = c("mL", "L", "fluid oz", "cup", "pint", "quart", "US gallon"), output = c("basic", "data.table") )drink_water_daily( mass, mass_unit = c("lb mass", "kg", "g"), water_unit = c("mL", "L", "fluid oz", "cup", "pint", "quart", "US gallon"), output = c("basic", "data.table") )
mass |
numeric vector that contains the mass |
mass_unit |
character vector that contains the mass units (options are
|
water_unit |
character vector that contains the water units (options are
|
output |
character vector that contains basic for the default result as
a vector or data.table for the result as a |
the amount of water in the given unit as a numeric vector or a data.table
with the amount of water in the following units: fluid oz, mL, L, cup,
pint, quart, and US gallon.
"Every twenty-four hours the body recycles the equivalent of forty thousand glasses of water to maintain its normal physiological functions. It does this every day of its life. Within this pattern of water metabolism and its recycling process, and depending on environmental conditions, the body becomes short of about six to ten glasses of water each day. This deficit has to be supplied to the body every day."
"If you think you are different and your body does not need this amount of water, you are making a major mistake. The body uses up the equivalent of between six to eight glasses of its total body water for essential functions. It needs on average upwards of half its weight in ounces of water per day—a minimum of eight to ten glasses. Water should be taken in eight- or sixteen- ounce portions spaced throughout the day. In the same way you don't let your car run out of gas before you fill the tank, the body must not be allowed to become dehydrated before you drink water." [Reference 2]
This function calculates the daily water intake based on a person's mass or weight according to the Batmanghelidj Reference.
Irucka Embry
Engineering Stack Exchange, "mechanical engineering - Pound-force (lbf) vs Pound-mass (lbm)", https://engineering.stackexchange.com/questions/2300/pound-force-lbf-vs-pound-mass-lbm.
F. Batmanghelidj, M.D., Water for Health, for Healing, for Life: You're Not Sick, You're Thirsty!, 2003, pages 149-150, ISBN#: 978-0-446-69074-4.
Wikimedia Foundation, Inc. Wikipedia, 11 August 2025, "Pound (force)", https://en.wikipedia.org/wiki/Pound_(force).
Wikimedia Foundation, Inc. Wikipedia, 20 August 2025, "Pound (mass)", https://en.wikipedia.org/wiki/Pound_(mass).
# Example 1 library(iemisc) mass <- 18 mass_unit <- "lb mass" water_unit <- "fluid oz" output <- "data.table" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output) # Example 2 library(iemisc) mass <- 8 mass_unit <- "g" water_unit <- "cup" output <- "data.table" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output) # Example 3 library(iemisc) mass <- 8 mass_unit <- "kg" water_unit <- "mL" output <- "basic" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output) # Example 4 library(iemisc) mass <- 79532.76 mass_unit <- "g" water_unit <- "quart" output <- "basic" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output)# Example 1 library(iemisc) mass <- 18 mass_unit <- "lb mass" water_unit <- "fluid oz" output <- "data.table" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output) # Example 2 library(iemisc) mass <- 8 mass_unit <- "g" water_unit <- "cup" output <- "data.table" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output) # Example 3 library(iemisc) mass <- 8 mass_unit <- "kg" water_unit <- "mL" output <- "basic" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output) # Example 4 library(iemisc) mass <- 79532.76 mass_unit <- "g" water_unit <- "quart" output <- "basic" drink_water_daily(mass, mass_unit = mass_unit, water_unit = water_unit, output = output)
This function solves for the absolute or dynamic viscosity of water using only the temperature of the water in either units of degrees Celsius, degrees Fahrenheit, or Kelvin.
dyn_visc_water( Temp, units = c("SI", "Eng", "Absolute"), Eng_units = c("slug/ft/s", "lbf*s/ft^2") )dyn_visc_water( Temp, units = c("SI", "Eng", "Absolute"), Eng_units = c("slug/ft/s", "lbf*s/ft^2") )
Temp |
numeric vector that contains the temperature (degrees Celsius, degrees Fahrenheit, or Kelvin) |
units |
character vector that contains the system of units [options are
|
Eng_units |
character vector that contains the unit for the dynamic viscosity of water in the English system [options are slug/ft/s or lbf*s/ft^2] |
The simplified equation is expressed as
with
Water Absolute or Dynamic Viscosity (kg/m*s, slug/ft/s, or lbf*s/ft^2)
the water temperature, degrees Celsius
the absolute or dynamic viscosity as a numeric vector. The units are not returned.
Irucka Embry
C. O. Popiel & J. Wojtkowiak (1998). "Simple Formulas for Thermophysical Properties of Liquid Water for Heat Transfer Calculations (from 0C to 150C)". Heat Transfer Engineering, 19:3, 87-101, article from ResearchGate: https://www.researchgate.net/publication/239243539_Simple_Formulas_for_Thermophysical_Properties_of_Liquid_Water_for_Heat_Transfer_Calculations_from_0C_to_150C.
# Example 1 (Compare to the tabulated values in the Reference paper) install.load::load_package("iemisc", "data.table", "round") Temp <- c(0, 0.01, 3.86, seq(5, 95, by = 5), 99.974, seq(100, 150, by = 5)) dynamic_viscosity <- data.table("Temperature (degrees C)" = Temp, "mu (* 10 ^ 6, kg / m*s)" = round_r3(dyn_visc_water(Temp, units = "SI") * 10^6, d = 1)) dynamic_viscosity # Example 2 - Example from the hydraulics package library(iemisc) mu <- hydraulics::dvisc(T = 55, units = "Eng"); mu mu2 <- dyn_visc_water(Temp = 55, units = "Eng", Eng_units = "lbf*s/ft^2"); mu2# Example 1 (Compare to the tabulated values in the Reference paper) install.load::load_package("iemisc", "data.table", "round") Temp <- c(0, 0.01, 3.86, seq(5, 95, by = 5), 99.974, seq(100, 150, by = 5)) dynamic_viscosity <- data.table("Temperature (degrees C)" = Temp, "mu (* 10 ^ 6, kg / m*s)" = round_r3(dyn_visc_water(Temp, units = "SI") * 10^6, d = 1)) dynamic_viscosity # Example 2 - Example from the hydraulics package library(iemisc) mu <- hydraulics::dvisc(T = 55, units = "Eng"); mu mu2 <- dyn_visc_water(Temp = 55, units = "Eng", Eng_units = "lbf*s/ft^2"); mu2
Computes the effective interest rate given the nominal interest rate per period
EffInt( r, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )EffInt( r, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
r |
numeric vector that contains the nominal interest rate(s) per period as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
i is expressed as
the "effective interest rate per interest period"
the "nominal interest rate"
the "number of compounding periods per year"
EffInt numeric vector that contains the effective interest rate
rounded to 2 decimal places (this is the i used in the other
Engineering Economics functions)
Irucka Embry
SFPE Handbook of Fire Protection Engineering. 3rd Edition, DiNenno, P. J.; Drysdale, D.; Beyler, C. L.; Walton, W. D., Editor(s), page 5-95, 2002. Chapter 7; Section 5; NFPA HFPE-02. See https://web.archive.org/web/20180127185316/http://fire.nist.gov/bfrlpubs/build02/PDF/b02155.pdf.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 164-165.
library(iemisc) # Example 4-28 from Sullivan Reference text (page 165) EffInt(1.375, frequency = "month") # the nominal interest rate per period (month) is 1.375\% # Example from SFPE Reference text EffInt(18 / 12, frequency = "month") # the nominal interest rate is 18\% per year or 18\% / 12 monthslibrary(iemisc) # Example 4-28 from Sullivan Reference text (page 165) EffInt(1.375, frequency = "month") # the nominal interest rate per period (month) is 1.375\% # Example from SFPE Reference text EffInt(18 / 12, frequency = "month") # the nominal interest rate is 18\% per year or 18\% / 12 months
Takes Kentucky or Tennessee-based Northing and Easting engineering survey measurements [based in the State Plane Coordinate System (SPCS)] in meters, international foot, or US survey foot and converts those values into geodetic coordinates of the World Geodetic System (WGS) (19)84 (EPSG:4326). [MapTiler Reference] Each latitude [Y] and longitude [X] point is verified to be located within Kentucky or Tennessee.
engr_survey( Northing, Easting, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "table"), utm = c(0, 1) )engr_survey( Northing, Easting, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "table"), utm = c(0, 1) )
Northing |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Easting engineering survey measurement in meters, international foot, or US survey foot |
units |
character vector that contains the system of units (options are
|
location |
character vector that contains the location name ('KY' for Kentucky or 'TN' for Tennessee) |
output |
character vector that contains basic for the default result
using a simple |
utm |
numeric vector that contains 0 or 1 only. 0 represents do not provide the utm coordinates and 1 is to provide the utm coordinates |
the projected associated latitude [Y] and longitude [X] coordinates
in Decimal Degrees as a data.table or as an
enhanced data.table with the latitude [Y] and
longitude [X] coordinates in Decimal Degrees, Degrees Minutes, Degrees
Minutes Seconds & the State Plane Northing and Easting coodinates in
meters, US survey foot, and the international foot
Please Note: If you have Kentucky North/South Zone survey measurements, then please use the Kentucky Geological Survey, University of Kentucky - Kentucky Single Coordinate Conversion Tool (http://kgs.uky.edu/kgsweb/CoordConversionTool.asp) instead. That tool will give you the geographic coordinates too. This R function, engr_survey will only be valid for NAD83 / Kentucky Single Zone.
Useful Tennessee reference Web site Tennessee Department of Transportation Roadway Design Survey Standards https://www.tn.gov/tdot/engineering-division/engineering-production-support/standard-drawings-library/standard-roadway-drawings/roadway-design-standards.html
Useful Kentucky reference Web site Kentucky Transportation Cabinet Survey Coordination https://transportation.ky.gov/Highway-Design/Pages/Survey-Coordination.aspx
Irucka Embry
Win-Vector Blog. John Mount, June 11, 2018, "R Tip: use isTRUE()", https://win-vector.com/2018/06/11/r-tip-use-istrue/.
Latitude Longitude Coordinates to State Code in R - Stack Overflow answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.
r - Convert column classes in data.table - Stack Overflow answered by Matt Dowle on Dec 27 2013. See https://stackoverflow.com/questions/7813578/convert-column-classes-in-data-table.
Excel vlook up function in R for data frame - Stack Overflow answered by Tyler Rinker on Apr 8 2013 and edited by Tyler Rinker on Feb 26 2014. See https://stackoverflow.com/questions/15882743/excel-vlook-up-function-in-r-for-data-frame.
r - Converting geo coordinates from degree to decimal - Stack Overflow answered by Robbes on Jan 3 2018 and edited by ayaio on Jan 3 2018. See https://stackoverflow.com/questions/14404596/converting-geo-coordinates-from-degree-to-decimal.
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.
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.
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Spatial Reference, Aug. 13, 2004, "EPSG:3088: NAD83 / Kentucky Single Zone", https://spatialreference.org/ref/epsg/3088/.
Spatial Reference, March 7, 2000, "EPSG:32136 NAD83 / Tennessee", https://spatialreference.org/ref/epsg/32136/.
MapTiler Team, "EPSG:4326: WGS 84 – WGS84 - World Geodetic System 1984, used in GPS, https://epsg.io/4326.
Tennessee Department of Transportation Design Division, Tennessee Department of Transportation Tennessee Geodetic Reference Network (TGRN) Reference Manual Second Edition Issued, page ix, https://www.tn.gov/content/dam/tn/tdot/documents/TgrnComposite.pdf.
Earth Point, "State Plane Coordinate System - Convert, View on Google Earth", https://www.earthpoint.us/StatePlane.aspx.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, Mid Valley Oil Rad Relay Twr designation, HA1363 PID, Grayson County Kentucky, Clarkson (1967) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=HA1363.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, 2006 42 07 designation, DL4005 PID, Fayette County Kentucky, Lexington West (1993) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=DL4005.
engr_surveyer for the wrapper function and engr_survey_batch for the multiple values function
# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Test 1 against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 1 is the station name with these coordinates # latitude (North) = 36 22 6.43923 # longitude (West) = 82 10 46.87679 library(iemisc) Northing_test1 <- 232489.480 # provided in TGRN Manual Easting_test1 <- 942754.124 # provided in TGRN Manual tgrn1 <- engr_survey(Northing_test1, Easting_test1, "meters", "TN", output = "table", utm = 0) tgrn1 # Test 2 against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 60 is the station name with these coordinates # latitude (North) = 35 8 46.44496 # longitude (West) = 89 54 24.04763 library(iemisc) Northing_test2 <- 97296.815 # provided in TGRN Manual Easting_test2 <- 244089.427 # provided in TGRN Manual tgrn2 <- engr_survey(Northing_test2, Easting_test2, "meters", "TN", output = "table", utm = 0) tgrn2 # Test 3 against the NGS Data sheet (Reference 7) # using the NAD 83(1993) DATUM # with these adjusted coordinates # latitude (North) = 37 24 17.73330 # longitude (West) = 086 14 14.18027 library(iemisc) # The following coordinates were computed from the latitude / longitude # using NAD 83(1993) Northing_test3 <- "1,119,041.443" # provided in NGS Data sheet Easting_test3 <- "1,456,861.006" # provided in NGS Data sheet ky1 <- engr_survey(Northing_test3, Easting_test3, "meters", "KY", output = "table", utm = 0) ky1 # Test 4 against the NGS Data sheet (Reference 8) # using the NAD 83(2011) DATUM # with these no check coordinates # latitude (North) = 38 04 23.86331 # longitude (West) = 084 32 04.55607 library(iemisc) # The following coordinates were computed from the latitude / longitude # using NAD 83(2011) Northing_test4 <- "3,671,388.47" # provided in NGS Data sheet Easting_test4 <- "4,779,718.15" # provided in NGS Data sheet ky2 <- engr_survey(Northing_test4, Easting_test4, "survey_ft", "KY", output = "table", utm = 0) ky2 # Example 1 # Kentucky (KY) Northing and Easting in US Survey foot library(iemisc) Northing1 <- 3807594.80077 Easting1 <- 5625162.88913 dt1 <- engr_survey(Northing = Northing1, Easting = Easting1, units = "survey_ft", location = "KY", output = "table", utm = 1) dt1 # Example 2 # Kentucky (KY) Northing and Easting in meters library(iemisc) Northing2 <- 1170338.983 Easting2 <- 1624669.125 dt2 <- engr_survey(Northing2, Easting2, "meters", "KY", output = "basic", utm = 0) dt2 # See Source 6 and Source 7 # Please see the error messages library(iemisc) # Tennessee (TN) Northing and Easting in US Survey foot Northing3 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting3 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") dt3 <- try(engr_survey(Northing3, Easting3, "survey_ft", "TN", output = "basic", utm = 0)) Northing4 <- c(232489.480, 234732.431) Easting4 <- c(942754.124, 903795.239) dt4 <- try(engr_survey(Northing4, Easting4, "survey_ft", "TN", output = "basic", utm = 0))# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Test 1 against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 1 is the station name with these coordinates # latitude (North) = 36 22 6.43923 # longitude (West) = 82 10 46.87679 library(iemisc) Northing_test1 <- 232489.480 # provided in TGRN Manual Easting_test1 <- 942754.124 # provided in TGRN Manual tgrn1 <- engr_survey(Northing_test1, Easting_test1, "meters", "TN", output = "table", utm = 0) tgrn1 # Test 2 against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 60 is the station name with these coordinates # latitude (North) = 35 8 46.44496 # longitude (West) = 89 54 24.04763 library(iemisc) Northing_test2 <- 97296.815 # provided in TGRN Manual Easting_test2 <- 244089.427 # provided in TGRN Manual tgrn2 <- engr_survey(Northing_test2, Easting_test2, "meters", "TN", output = "table", utm = 0) tgrn2 # Test 3 against the NGS Data sheet (Reference 7) # using the NAD 83(1993) DATUM # with these adjusted coordinates # latitude (North) = 37 24 17.73330 # longitude (West) = 086 14 14.18027 library(iemisc) # The following coordinates were computed from the latitude / longitude # using NAD 83(1993) Northing_test3 <- "1,119,041.443" # provided in NGS Data sheet Easting_test3 <- "1,456,861.006" # provided in NGS Data sheet ky1 <- engr_survey(Northing_test3, Easting_test3, "meters", "KY", output = "table", utm = 0) ky1 # Test 4 against the NGS Data sheet (Reference 8) # using the NAD 83(2011) DATUM # with these no check coordinates # latitude (North) = 38 04 23.86331 # longitude (West) = 084 32 04.55607 library(iemisc) # The following coordinates were computed from the latitude / longitude # using NAD 83(2011) Northing_test4 <- "3,671,388.47" # provided in NGS Data sheet Easting_test4 <- "4,779,718.15" # provided in NGS Data sheet ky2 <- engr_survey(Northing_test4, Easting_test4, "survey_ft", "KY", output = "table", utm = 0) ky2 # Example 1 # Kentucky (KY) Northing and Easting in US Survey foot library(iemisc) Northing1 <- 3807594.80077 Easting1 <- 5625162.88913 dt1 <- engr_survey(Northing = Northing1, Easting = Easting1, units = "survey_ft", location = "KY", output = "table", utm = 1) dt1 # Example 2 # Kentucky (KY) Northing and Easting in meters library(iemisc) Northing2 <- 1170338.983 Easting2 <- 1624669.125 dt2 <- engr_survey(Northing2, Easting2, "meters", "KY", output = "basic", utm = 0) dt2 # See Source 6 and Source 7 # Please see the error messages library(iemisc) # Tennessee (TN) Northing and Easting in US Survey foot Northing3 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting3 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") dt3 <- try(engr_survey(Northing3, Easting3, "survey_ft", "TN", output = "basic", utm = 0)) Northing4 <- c(232489.480, 234732.431) Easting4 <- c(942754.124, 903795.239) dt4 <- try(engr_survey(Northing4, Easting4, "survey_ft", "TN", output = "basic", utm = 0))
Takes Kentucky or Tennessee-based Northing and Easting engineering survey measurements [based in the State Plane Coordinate System (SPCS)] in meters, international foot, or US survey foot and converts those values into geodetic coordinates of the World Geodetic System (WGS) (19)84 (EPSG:4326). [MapTiler Reference] Each latitude [Y] and longitude [X] point is verified to be located within Kentucky or Tennessee. This is the batch version of engr_survey as it processes multiple pairs of Northing and Easting points at a time.
engr_survey_batch( Northing, Easting, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "table"), utm = c(0, 1) )engr_survey_batch( Northing, Easting, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "table"), utm = c(0, 1) )
Northing |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot [a minimum of 2 points each time] |
Easting |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Easting engineering survey measurement in meters, international foot, or US survey foot [a minimum of 2 points each time] |
units |
character vector that contains the system of units (options are
|
location |
character vector that contains the location name ('KY' for Kentucky or 'TN' for Tennessee) [only 1 location at a time] |
output |
character vector that contains basic for the default result
using a simple |
utm |
numeric vector that contains 0 or 1 only. 0 represents do not provide the utm coordinates and 1 is to provide the utm coordinates |
the projected associated latitude [Y] and longitude [X] coordinates
in Decimal Degrees as a data.table or as an
enhanced data.table with the latitude [Y] and
longitude [X] coordinates in Decimal Degrees, Degrees Minutes, Degrees
Minutes Seconds & the State Plane Northing and Easting coodinates in
meters, US survey foot, and the international foot
Please Note: If you have Kentucky North/South Zone survey measurements, then
please use the Kentucky Geological Survey, University of Kentucky - Kentucky
Single Coordinate Conversion Tool
(http://kgs.uky.edu/kgsweb/CoordConversionTool.asp) instead. That tool will
give you the geographic coordinates too. This R function, engr_survey_batch
will only be valid for NAD83 / Kentucky Single Zone.
Useful Tennessee reference Web site Tennessee Department of Transportation Roadway Design Survey Standards https://www.tn.gov/tdot/engineering-division/engineering-production-support/standard-drawings-library/standard-roadway-drawings/roadway-design-standards.html
Useful Kentucky reference Web site Kentucky Transportation Cabinet Survey Coordination https://transportation.ky.gov/Highway-Design/Pages/Survey-Coordination.aspx
Irucka Embry
Win-Vector Blog. John Mount, June 11, 2018, "R Tip: use isTRUE()", https://win-vector.com/2018/06/11/r-tip-use-istrue/.
Latitude Longitude Coordinates to State Code in R - Stack Overflow answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.
r - Convert column classes in data.table - Stack Overflow answered by Matt Dowle on Dec 27 2013. See https://stackoverflow.com/questions/7813578/convert-column-classes-in-data-table.
Excel vlook up function in R for data frame - Stack Overflow answered by Tyler Rinker on Apr 8 2013 and edited by Tyler Rinker on Feb 26 2014. See https://stackoverflow.com/questions/15882743/excel-vlook-up-function-in-r-for-data-frame.
r - Converting geo coordinates from degree to decimal - Stack Overflow answered by Robbes on Jan 3 2018 and edited by ayaio on Jan 3 2018. See https://stackoverflow.com/questions/14404596/converting-geo-coordinates-from-degree-to-decimal.
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.
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.
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Spatial Reference, Aug. 13, 2004, "EPSG:3088: NAD83 / Kentucky Single Zone", https://spatialreference.org/ref/epsg/3088/.
Spatial Reference, March 7, 2000, "EPSG:32136 NAD83 / Tennessee", https://spatialreference.org/ref/epsg/32136/.
MapTiler Team, "EPSG:4326: WGS 84 – WGS84 - World Geodetic System 1984, used in GPS, https://epsg.io/4326.
Tennessee Department of Transportation Design Division, Tennessee Department of Transportation Tennessee Geodetic Reference Network (TGRN) Reference Manual Second Edition Issued, page ix, https://www.tn.gov/content/dam/tn/tdot/documents/TgrnComposite.pdf.
Earth Point, "State Plane Coordinate System - Convert, View on Google Earth", https://www.earthpoint.us/StatePlane.aspx.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, Mid Valley Oil Rad Relay Twr designation, HA1363 PID, Grayson County Kentucky, Clarkson (1967) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=HA1363.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, 2006 42 07 designation, DL4005 PID, Fayette County Kentucky, Lexington West (1993) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=DL4005.
engr_surveyer for the wrapper function and engr_survey for the single value function
# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Example 1 # Tennessee (TN) Northing and Easting in US Survey foot library(iemisc) Northing1 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting1 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") dt1 <- engr_survey_batch(Northing1, Easting1, "survey_ft", "TN", output = "basic", utm = 1) dt1 # See Source 6 and Source 7 # Please see the error messages library(iemisc) Northing1 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting1 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") Northing2 <- c(232489.480, 234732.431) Easting2 <- c(942754.124, 903795.239) dt1A <- try(engr_survey_batch(Northing1[1], Easting1[1], "survey_ft", "TN", output = "basic", utm = 1)) dt1A # first set of Northing, Easting points dt1B <- try(engr_survey_batch(Northing1[2], Easting1[2], "survey_ft", "TN", output = "basic", utm = 1)) dt1B # second set of Northing, Easting points dt1C <- try(engr_survey_batch(Northing1[3], Easting1[3], "survey_ft", "TN", output = "basic", utm = 1)) dt1C # third set of Northing, Easting points dt1D <- try(engr_survey_batch(Northing1[4], Easting1[4], "survey_ft", "TN", output = "basic", utm = 1)) dt1D # fourth set of Northing, Easting points dt4A <- try(engr_survey_batch(Northing2[1], Easting2[1], "meters", "TN", output = "table", utm = 1)) dt4A dt4B <- try(engr_survey_batch(Northing2[2], Easting2[2], "meters", "TN", output = "table", utm = 1)) dt4B# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Example 1 # Tennessee (TN) Northing and Easting in US Survey foot library(iemisc) Northing1 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting1 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") dt1 <- engr_survey_batch(Northing1, Easting1, "survey_ft", "TN", output = "basic", utm = 1) dt1 # See Source 6 and Source 7 # Please see the error messages library(iemisc) Northing1 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting1 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") Northing2 <- c(232489.480, 234732.431) Easting2 <- c(942754.124, 903795.239) dt1A <- try(engr_survey_batch(Northing1[1], Easting1[1], "survey_ft", "TN", output = "basic", utm = 1)) dt1A # first set of Northing, Easting points dt1B <- try(engr_survey_batch(Northing1[2], Easting1[2], "survey_ft", "TN", output = "basic", utm = 1)) dt1B # second set of Northing, Easting points dt1C <- try(engr_survey_batch(Northing1[3], Easting1[3], "survey_ft", "TN", output = "basic", utm = 1)) dt1C # third set of Northing, Easting points dt1D <- try(engr_survey_batch(Northing1[4], Easting1[4], "survey_ft", "TN", output = "basic", utm = 1)) dt1D # fourth set of Northing, Easting points dt4A <- try(engr_survey_batch(Northing2[1], Easting2[1], "meters", "TN", output = "table", utm = 1)) dt4A dt4B <- try(engr_survey_batch(Northing2[2], Easting2[2], "meters", "TN", output = "table", utm = 1)) dt4B
Takes geodetic coordinates of the World Geodetic System (WGS) (19)84 (EPSG:4326) [MapTiler Reference] and converts those values into Kentucky or Tennessee-based Northing and Easting engineering survey measurements [based in the State Plane Coordinate System (SPCS)] in meters, international foot, or US survey foot. Each latitude [Y] and longitude [X] point is verified to be located within Kentucky or Tennessee.
engr_survey_reverse( latitude, longitude, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "table"), utm = c(0, 1) )engr_survey_reverse( latitude, longitude, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("basic", "table"), utm = c(0, 1) )
latitude |
numeric vector [or character vector with spaces, degree symbol, single quotation mark, and/or escaped quotation mark (\")] that contains the latitude coordinate point. The following possibilities are valid: -25.02, "25\U00B056'50.2068\"N"; "15\U00B056'58.7068"; "37'1'54.3'N"; "35 8 46.44496", "35'8'46.44496". If the North designation is not provided, then it will be added. The latitude/longitude coordinate pair has to be either a numeric or character vector (no mixing). |
longitude |
numeric vector [or character vector with spaces, degree symbol, single quotation mark, and/or escaped quotation mark (\")] that contains the latitude coordinate point. The following possibilities are valid: 09.83, "25\U00B056'50.2068\"W"; "15\U00B056'58.7068"; "37'1'54.3'E"; "35 8 46.44496", "35'8'46.44496". If the West designation is not provided, then it will be added. The latitude/longitude coordinate pair has to be either a numeric or character vector (no mixing). |
units |
character vector that contains the system of units (options are
|
location |
character vector that contains the location name ('KY' for Kentucky or 'TN' for Tennessee) |
output |
character vector that contains basic for the default result
using a simple |
utm |
numeric vector that contains 0 or 1 only. 0 represents do not provide the utm coordinates and 1 is to provide the utm coordinates |
the geodetic coordinates as projected SPCS Northing and Easting
coordinates as a data.table
Please Note: If you have Kentucky North/South Zone survey measurements, then
please use the Kentucky Geological Survey, University of Kentucky - Kentucky
Single Coordinate Conversion Tool
(http://kgs.uky.edu/kgsweb/CoordConversionTool.asp) instead. That tool will
give you the geographic coordinates too. This R function, engr_survey_reverse
will only be valid for NAD83 / Kentucky Single Zone.
Useful Tennessee reference Web site Tennessee Department of Transportation Roadway Design Survey Standards (https://www.tn.gov/tdot/engineering-division/engineering-production-support/standard-drawings-library/standard-roadway-drawings/roadway-design-standards.html)
Useful Kentucky reference Web site Kentucky Transportation Cabinet Survey Coordination (https://transportation.ky.gov/Highway-Design/Pages/Survey-Coordination.aspx)
Irucka Embry, Berry Boessenkool (a couple of functions are sourced from OSMscale)
Win-Vector Blog. John Mount, June 11, 2018, "R Tip: use isTRUE()", https://win-vector.com/2018/06/11/r-tip-use-istrue/.
Latitude Longitude Coordinates to State Code in R - Stack Overflow answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.
r - Convert column classes in data.table - Stack Overflow answered by Matt Dowle on Dec 27 2013. See https://stackoverflow.com/questions/7813578/convert-column-classes-in-data-table.
Excel vlook up function in R for data frame - Stack Overflow answered by Tyler Rinker on Apr 8 2013 and edited by Tyler Rinker on Feb 26 2014. See https://stackoverflow.com/questions/15882743/excel-vlook-up-function-in-r-for-data-frame.
r - Converting geo coordinates from degree to decimal - Stack Overflow answered by Robbes on Jan 3 2018 and edited by ayaio on Jan 3 2018. See https://stackoverflow.com/questions/14404596/converting-geo-coordinates-from-degree-to-decimal.
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Spatial Reference, Aug. 13, 2004, "EPSG:3088: NAD83 / Kentucky Single Zone", https://spatialreference.org/ref/epsg/3088/.
Spatial Reference, March 7, 2000, "EPSG:32136 NAD83 / Tennessee", https://spatialreference.org/ref/epsg/32136/.
MapTiler Team, "EPSG:4326: WGS 84 – WGS84 - World Geodetic System 1984, used in GPS, https://epsg.io/4326.
Tennessee Department of Transportation Design Division, Tennessee Department of Transportation Tennessee Geodetic Reference Network (TGRN) Reference Manual Second Edition Issued, page ix, https://www.tn.gov/content/dam/tn/tdot/documents/TgrnComposite.pdf.
Earth Point, "State Plane Coordinate System - Convert, View on Google Earth", https://www.earthpoint.us/StatePlane.aspx.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, Mid Valley Oil Rad Relay Twr designation, HA1363 PID, Grayson County Kentucky, Clarkson (1967) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=HA1363.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, 2006 42 07 designation, DL4005 PID, Fayette County Kentucky, Lexington West (1993) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=DL4005.
engr_surveyer for the wrapper function
# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Test against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 60 is the station name with these coordinates # latitude (North) = 35 8 46.44496 # longitude (West) = 89 54 24.04763 # Northing is 97296.815 # provided in TGRN Manual # Easting is 244089.427 # provided in TGRN Manual library(iemisc) latitude <- "35 8 46.44496" longitude <- "89 54 24.04763" Northing_test2 <- 97296.815 # provided in TGRN Manual Easting_test2 <- 244089.427 # provided in TGRN Manual tgrn2A <- engr_survey_reverse(latitude, longitude, "meters", "TN", output = "table", utm = 0) tgrn2A tgrn2B <- engr_survey(Northing_test2, Easting_test2, "meters", "TN", output = "table", utm = 0) tgrn2B # Example 1 # Tennessee library(iemisc) lat <- 35.8466965 long <- -88.9206794 dt1B <- engr_survey_reverse(lat, long, units = "survey_ft", location = "TN", output = "basic", utm = 1) dt1B # Example 2 # Kentucky library(iemisc) lats <- "37'50'21.5988''N" longs <- "84'16'12.0720'W" dt2A <- engr_survey_reverse(lats, longs, "foot", "KY", output = "basic", utm = 0) dt2A# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Test against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 60 is the station name with these coordinates # latitude (North) = 35 8 46.44496 # longitude (West) = 89 54 24.04763 # Northing is 97296.815 # provided in TGRN Manual # Easting is 244089.427 # provided in TGRN Manual library(iemisc) latitude <- "35 8 46.44496" longitude <- "89 54 24.04763" Northing_test2 <- 97296.815 # provided in TGRN Manual Easting_test2 <- 244089.427 # provided in TGRN Manual tgrn2A <- engr_survey_reverse(latitude, longitude, "meters", "TN", output = "table", utm = 0) tgrn2A tgrn2B <- engr_survey(Northing_test2, Easting_test2, "meters", "TN", output = "table", utm = 0) tgrn2B # Example 1 # Tennessee library(iemisc) lat <- 35.8466965 long <- -88.9206794 dt1B <- engr_survey_reverse(lat, long, units = "survey_ft", location = "TN", output = "basic", utm = 1) dt1B # Example 2 # Kentucky library(iemisc) lats <- "37'50'21.5988''N" longs <- "84'16'12.0720'W" dt2A <- engr_survey_reverse(lats, longs, "foot", "KY", output = "basic", utm = 0) dt2A
Takes engineering survey points in various units (foot, US survey foot, meters, or kilometers) and calculates the horizontal length in various units (foot, US survey foot, US survey mile, mile, meters, or kilometers).
engr_survey2( station1, station2, station_distance = 100, units1 = c("foot", "survey_ft", "meters", "kilometers"), units2 = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers") )engr_survey2( station1, station2, station_distance = 100, units1 = c("foot", "survey_ft", "meters", "kilometers"), units2 = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers") )
station1 |
character vector that contains the begin engineering survey station value |
station2 |
character vector that contains the end engineering survey station value |
station_distance |
numeric vector that contains the horizontal distance between any 2 points along the survey, the default is 100 feet |
units1 |
character vector that contains the system of units for the
|
units2 |
character vector that contains the system of units for the
horizontal length (options are |
the calculated horizontal distance in the chosen unit as a numeric vector with the units attached
Irucka Embry
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Ben W. Lewis, PE, July 12, 2016, "Construction Plan Reading Basics & Applications Part III Typical Calculations / Quantity Take-off's: Calculate Project Length", https://web.archive.org/web/20171008121149/http://www.richlandonline.com/Portals/0/Departments/Procurement/SLBE/Plan%20Reading%20PowerPoint%20Presentation.pdf. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Georgia Department of Transportation Skills Development Series, Revised May 1, 2008, "Basic Highway Plan Reading", https://web.archive.org/web/20220401015405/http://www.dot.ga.gov/PartnerSmart/Training/Documents/ESD/BasicHiwyPlanReading.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
engr_surveyer for the wrapper function
# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Example 1 library(iemisc) engr_survey2("395+75", "397+13", station_distance = 100, units1 = "foot", units2 = "foot") # Example 2 library(iemisc) station1 <- "333+03" station2 <- "332+94" engr_survey2(station1, station2, units1 = "foot", units2 = "survey_mile") # Example 3 from Lewis Reference document page 25 library(iemisc) station3 <- "10+25.62" station4 <- "189+45.72" engr_survey2(station3, station4, units1 = "foot", units2 = "mile") # Example 4 from Georgia reference page 27 (document page 43) library(iemisc) engr_survey2("701+50.00", "409+69.00", station_distance = 100, units1 = "survey_ft", units2 = "foot")# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Example 1 library(iemisc) engr_survey2("395+75", "397+13", station_distance = 100, units1 = "foot", units2 = "foot") # Example 2 library(iemisc) station1 <- "333+03" station2 <- "332+94" engr_survey2(station1, station2, units1 = "foot", units2 = "survey_mile") # Example 3 from Lewis Reference document page 25 library(iemisc) station3 <- "10+25.62" station4 <- "189+45.72" engr_survey2(station3, station4, units1 = "foot", units2 = "mile") # Example 4 from Georgia reference page 27 (document page 43) library(iemisc) engr_survey2("701+50.00", "409+69.00", station_distance = 100, units1 = "survey_ft", units2 = "foot")
Takes engineering survey points in various units (foot, US survey foot, meters, or kilometers) and calculates the horizontal length in various units (foot, US survey foot, US survey mile, mile, meters, or kilometers).
engr_survey3( length1, station_distance = 100, units = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers"), output = c("numeric", "string") )engr_survey3( length1, station_distance = 100, units = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers"), output = c("numeric", "string") )
length1 |
character vector that contains the beginning engineering survey station value |
station_distance |
numeric vector that contains the horizontal distance between any 2 points along the survey, the default is 100 feet |
units |
character vector that contains the system of units for the
|
output |
character vector that contains the system of units for the
horizontal length (options are |
horizontal length as a numeric vector (ex. 1214.402) or as a character vector with the word stations after the number (ex. 1214.402 stations)
Irucka Embry
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Engineer Boards: Transportation. "Stationing. Dumb question?" Question asked by By NIKE, August 31, 2013 and answered by ptatohed on September 1, 2013. See https://engineerboards.com/threads/stationing-dumb-question.21935/.
engr_surveyer for the wrapper function
# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Example 1 library(iemisc) # "What the others said is correct. 1 station is equal to 100 feet. So when # asked how many stations are in (3.2mi x 5280ft/mi = ) 16,896 feet, you are being # asked how many 100 foot-segments are in 16,896 feet? The answer of course is # 16,896ft / 100ft/sta = 168.96 sta." Source: Reference 2 length1 <- "16,896" # feet engr_survey3(length1, station_distance = 100, units = "foot", output = "numeric") engr_survey3(length1, station_distance = 100, units = "foot", output = "string") # the answer provides the number of stations # Note: Both answers should be the same as 3.2 miles = 16,896 feet. length2 <- 3.2 # miles engr_survey3(length2, station_distance = 100, units = "mile", output = "numeric") engr_survey3(length2, station_distance = 100, units = "mile", output = "string") # the answer provides the number of stations# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples # Example 1 library(iemisc) # "What the others said is correct. 1 station is equal to 100 feet. So when # asked how many stations are in (3.2mi x 5280ft/mi = ) 16,896 feet, you are being # asked how many 100 foot-segments are in 16,896 feet? The answer of course is # 16,896ft / 100ft/sta = 168.96 sta." Source: Reference 2 length1 <- "16,896" # feet engr_survey3(length1, station_distance = 100, units = "foot", output = "numeric") engr_survey3(length1, station_distance = 100, units = "foot", output = "string") # the answer provides the number of stations # Note: Both answers should be the same as 3.2 miles = 16,896 feet. length2 <- 3.2 # miles engr_survey3(length2, station_distance = 100, units = "mile", output = "numeric") engr_survey3(length2, station_distance = 100, units = "mile", output = "string") # the answer provides the number of stations
Takes engineering survey points in various units (foot, US survey foot, meters, or kilometers) and determines the upstream station location.
engr_survey4( object, ds_station, station_distance = 100, units = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers") )engr_survey4( object, ds_station, station_distance = 100, units = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers") )
object |
numeric vector that contains the upstream length |
ds_station |
character vector that contains the ending engineering survey station value |
station_distance |
numeric vector that contains the horizontal distance between any 2 points along the survey, the default is 100 feet |
units |
character vector that contains the system of units for the
|
the final engineering survey position (ex. Sta. 5+55)
Irucka Embry
r - Insert a character at a specific location in a string - Stack Overflow answered and edited by Justin on Dec 13 2012. See https://stackoverflow.com/questions/13863599/insert-a-character-at-a-specific-location-in-a-string.
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Engineer Boards: Transportation. "Stationing. Dumb question?" Question asked by By NIKE, August 31, 2013 and answered by ptatohed on September 1, 2013. See https://engineerboards.com/threads/stationing-dumb-question.21935/.
engr_surveyer for the wrapper function
# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples library(iemisc) # Example 1 # "Conversely, if you were asked at what station a manhole 555 ft upstream of # Sta 0+00 is, your answer would be 0.00 sta + 555 ft / 100 ft/sta = 5.55 sta = # Sta 5+55." Source: Reference 2 engr_survey4(555, "0+00", units = "foot")# Please refer to the iemisc: Engineering Survey Examples vignette for # additional examples library(iemisc) # Example 1 # "Conversely, if you were asked at what station a manhole 555 ft upstream of # Sta 0+00 is, your answer would be 0.00 sta + 555 ft / 100 ft/sta = 5.55 sta = # Sta 5+55." Source: Reference 2 engr_survey4(555, "0+00", units = "foot")
Wrapper function to the project_midpoint, engr_survey/engr_survey_batch, engr_survey2, engr_survey3, engr_survey4, and engr_survey_reverse functions.
engr_surveyer( Northing = NULL, Easting = NULL, latitude = NULL, longitude = NULL, Northing_begin = NULL, Easting_begin = NULL, Northing_end = NULL, Easting_end = NULL, station1 = NULL, station2 = NULL, length1 = NULL, object = NULL, ds_station = NULL, station_distance = 100, location = c("KY", "TN"), utm = c(0, 1), units = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers"), units1 = c("foot", "survey_ft", "meters", "kilometers"), units2 = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers"), output = c("basic", "table", "simple", "advanced", "numeric", "string"), engr_surv_choice = c("project_midpoint", "engr_survey", "engr_survey2", "engr_survey3", "engr_survey4", "engr_survey_reverse") )engr_surveyer( Northing = NULL, Easting = NULL, latitude = NULL, longitude = NULL, Northing_begin = NULL, Easting_begin = NULL, Northing_end = NULL, Easting_end = NULL, station1 = NULL, station2 = NULL, length1 = NULL, object = NULL, ds_station = NULL, station_distance = 100, location = c("KY", "TN"), utm = c(0, 1), units = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers"), units1 = c("foot", "survey_ft", "meters", "kilometers"), units2 = c("foot", "survey_ft", "survey_mile", "mile", "meters", "kilometers"), output = c("basic", "table", "simple", "advanced", "numeric", "string"), engr_surv_choice = c("project_midpoint", "engr_survey", "engr_survey2", "engr_survey3", "engr_survey4", "engr_survey_reverse") )
Northing |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Easting engineering survey measurement in meters, international foot, or US survey foot |
latitude |
numeric vector [or character vector with spaces, degree symbol, single quotation mark, and/or escaped quotation mark (\")] that contains the latitude coordinate point. The following possibilities are valid: -25.02, "25\U00B056'50.2068\"N"; "15\U00B056'58.7068"; "37'1'54.3'N"; "35 8 46.44496", "35'8'46.44496". If the North designation is not provided, then it will be added. The latitude/longitude coordinate pair has to be either a numeric or character vector (no mixing). |
longitude |
numeric vector [or character vector with spaces, degree symbol, single quotation mark, and/or escaped quotation mark (\")] that contains the latitude coordinate point. The following possibilities are valid: 09.83, "25\U00B056'50.2068\"W"; "15\U00B056'58.7068"; "37'1'54.3'E"; "35 8 46.44496", "35'8'46.44496". If the West designation is not provided, then it will be added. The latitude/longitude coordinate pair has to be either a numeric or character vector (no mixing). |
Northing_begin |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting_begin |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Northing_end |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting_end |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
station1 |
character vector that contains the begin engineering survey station value |
station2 |
character vector that contains the end engineering survey station value |
length1 |
character vector that contains the beginning engineering survey station value |
object |
numeric vector that contains the upstream length |
ds_station |
character vector that contains the ending engineering survey station value |
station_distance |
numeric vector that contains the horizontal distance between any 2 points along the survey, the default is 100 feet |
location |
character vector that contains the location name ('KY' for Kentucky or 'TN' for Tennessee) [only 1 location at a time] |
utm |
numeric vector that contains 0 or 1 only. 0 represents do not provide the utm coordinates and 1 is to provide the utm coordinates |
units |
character vector that contains the system of units for the
|
units1 |
character vector that contains the system of units for the
|
units2 |
character vector that contains the system of units for the
horizontal length (options are |
output |
character vector that contains the system of units for the
horizontal length (options are |
engr_surv_choice |
character vector that contains the engineering survey function (project_midpoint, engr_survey [for engr_survey or engr_survey_batch], engr_survey2, engr_survey3, engr_survey4, engr_survey_reverse) |
Please refer to the return sections of the functions for more details.
Irucka Embry
r - How to pass alternative arguments through wrapper function? - Stack Overflow answered by G. Grothendieck on Oct 8, 2013 and edited by Ricardo Guerreiro on Dec 21, 2018. See https://stackoverflow.com/questions/19258574/how-to-pass-alternative-arguments-through-wrapper-function.
project_midpoint, engr_survey, engr_survey_batch, engr_survey2,
engr_survey3, engr_survey4, and engr_survey_reverse.
# Example 1 (Engineering Survey and Engineering Survey Batch) # Modified from engr_survey_batch Example library(iemisc) Northing1 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting1 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") Northing2 <- c(232489.480, 234732.431) Easting2 <- c(942754.124, 903795.239) dt1A <- engr_surveyer(Northing = Northing1[1], Easting = Easting1[1], units = "survey_ft", location = "TN", output = "table", utm = 1, engr_surv_choice = "engr_survey") dt1A # first set of Northing, Easting points dt1B <- engr_surveyer(Northing = Northing1, Easting = Easting1, units = "survey_ft", location = "TN", output = "table", utm = 1, engr_surv_choice = "engr_survey") dt1B # all Northing and Easting points # Example 2 (Engineering Survey and Engineering Survey Batch) # Modified from engr_survey Example # Test 1 against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 1 is the station name with these coordinates # latitude (North) = 36 22 6.43923 # longitude (West) = 82 10 46.87679 library(iemisc) Northing_test1 <- 232489.480 # provided in TGRN Manual Easting_test1 <- 942754.124 # provided in TGRN Manual tgrn1 <- engr_surveyer(Northing = Northing_test1, Easting = Easting_test1, units = "meters", location = "TN", output = "table", utm = 0, engr_surv_choice = "engr_survey") tgrn1 Northing <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") dt1 <- engr_surveyer(Northing = Northing1, Easting = Easting1, units = "survey_ft", location = "TN", output = "table", utm = 0, engr_surv_choice = "engr_survey") dt1 # Example 3 (Engineering Survey 2) # Modified from engr_survey2 Example 1 library(iemisc) engr_surveyer(station1 = "395+75", station2 = "397+13", station_distance = 100, units1 = "foot", units2 = "foot", engr_surv_choice = "engr_survey2") # Example 4 (Engineering Survey 3) # Modified from engr_survey3 Example 1 library(iemisc) # "What the others said is correct. 1 station is equal to 100 feet. So when # asked how many stations are in (3.2mi x 5280ft/mi = ) 16,896 feet, you are being # asked how many 100 foot-segments are in 16,896 feet? The answer of course is # 16,896ft / 100ft/sta = 168.96 sta." Source: Reference 2 length1 <- "16,896" # feet engr_surveyer(length1 = length1, station_distance = 100, units = "foot", output = "numeric", engr_surv_choice = "engr_survey3") engr_surveyer(length1 = length1, station_distance = 100, units = "foot", output = "string", engr_surv_choice = "engr_survey3") # the answer provides the number of stations # Note: Both answers should be the same as 3.2 miles = 16,896 feet. length2 <- 3.2 # miles engr_surveyer(length1 = length2, station_distance = 100, units = "mile", output = "numeric", engr_surv_choice = "engr_survey3") engr_surveyer(length1 = length2, station_distance = 100, units = "mile", output = "string", engr_surv_choice = "engr_survey3") # the answer provides the number of stations # Example 5 (Engineering Survey 3) # Modified from engr_survey4 Example 1 library(iemisc) # "Conversely, if you were asked at what station a manhole 555 ft upstream of # Sta 0+00 is, your answer would be 0.00 sta + 555 ft / 100 ft/sta = 5.55 sta = # Sta 5+55." Source: Reference 2 engr_surveyer(object = 555, ds_station = "0+00", station_distance = 100, units = "foot", engr_surv_choice = "engr_survey4") # Example 6 (Engineering Survey 3) # Modified from engr_survey_reverse Example 1 # Tennessee library(iemisc) lat <- 35.8466965 long <- -88.9206794 dt1C <- engr_surveyer(latitude = lat, longitude = long, units = "survey_ft", location = "TN", output = "basic", utm = 1, engr_surv_choice = "engr_survey_reverse") dt1C # Example 7 (Engineering Survey 3) # Modified from project_midpoint Example 1 library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 engr_surveyer(Northing_begin = Northing_begin, Easting_begin = Easting_begin, Northing_end = Northing_end, Easting_end = Easting_end, units = "survey_ft", location = "TN", output = "simple", engr_surv_choice = "project_midpoint")# Example 1 (Engineering Survey and Engineering Survey Batch) # Modified from engr_survey_batch Example library(iemisc) Northing1 <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting1 <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") Northing2 <- c(232489.480, 234732.431) Easting2 <- c(942754.124, 903795.239) dt1A <- engr_surveyer(Northing = Northing1[1], Easting = Easting1[1], units = "survey_ft", location = "TN", output = "table", utm = 1, engr_surv_choice = "engr_survey") dt1A # first set of Northing, Easting points dt1B <- engr_surveyer(Northing = Northing1, Easting = Easting1, units = "survey_ft", location = "TN", output = "table", utm = 1, engr_surv_choice = "engr_survey") dt1B # all Northing and Easting points # Example 2 (Engineering Survey and Engineering Survey Batch) # Modified from engr_survey Example # Test 1 against TGRN Manual (Reference 5) # using the 1983 (1995) DATUM # GPS 1 is the station name with these coordinates # latitude (North) = 36 22 6.43923 # longitude (West) = 82 10 46.87679 library(iemisc) Northing_test1 <- 232489.480 # provided in TGRN Manual Easting_test1 <- 942754.124 # provided in TGRN Manual tgrn1 <- engr_surveyer(Northing = Northing_test1, Easting = Easting_test1, units = "meters", location = "TN", output = "table", utm = 0, engr_surv_choice = "engr_survey") tgrn1 Northing <- c("630817.6396", "502170.6065", "562,312.2349", "574,370.7178") Easting <- c("2559599.9201", "1433851.6509", "1,843,018.4099", "1,854,896.0041") dt1 <- engr_surveyer(Northing = Northing1, Easting = Easting1, units = "survey_ft", location = "TN", output = "table", utm = 0, engr_surv_choice = "engr_survey") dt1 # Example 3 (Engineering Survey 2) # Modified from engr_survey2 Example 1 library(iemisc) engr_surveyer(station1 = "395+75", station2 = "397+13", station_distance = 100, units1 = "foot", units2 = "foot", engr_surv_choice = "engr_survey2") # Example 4 (Engineering Survey 3) # Modified from engr_survey3 Example 1 library(iemisc) # "What the others said is correct. 1 station is equal to 100 feet. So when # asked how many stations are in (3.2mi x 5280ft/mi = ) 16,896 feet, you are being # asked how many 100 foot-segments are in 16,896 feet? The answer of course is # 16,896ft / 100ft/sta = 168.96 sta." Source: Reference 2 length1 <- "16,896" # feet engr_surveyer(length1 = length1, station_distance = 100, units = "foot", output = "numeric", engr_surv_choice = "engr_survey3") engr_surveyer(length1 = length1, station_distance = 100, units = "foot", output = "string", engr_surv_choice = "engr_survey3") # the answer provides the number of stations # Note: Both answers should be the same as 3.2 miles = 16,896 feet. length2 <- 3.2 # miles engr_surveyer(length1 = length2, station_distance = 100, units = "mile", output = "numeric", engr_surv_choice = "engr_survey3") engr_surveyer(length1 = length2, station_distance = 100, units = "mile", output = "string", engr_surv_choice = "engr_survey3") # the answer provides the number of stations # Example 5 (Engineering Survey 3) # Modified from engr_survey4 Example 1 library(iemisc) # "Conversely, if you were asked at what station a manhole 555 ft upstream of # Sta 0+00 is, your answer would be 0.00 sta + 555 ft / 100 ft/sta = 5.55 sta = # Sta 5+55." Source: Reference 2 engr_surveyer(object = 555, ds_station = "0+00", station_distance = 100, units = "foot", engr_surv_choice = "engr_survey4") # Example 6 (Engineering Survey 3) # Modified from engr_survey_reverse Example 1 # Tennessee library(iemisc) lat <- 35.8466965 long <- -88.9206794 dt1C <- engr_surveyer(latitude = lat, longitude = long, units = "survey_ft", location = "TN", output = "basic", utm = 1, engr_surv_choice = "engr_survey_reverse") dt1C # Example 7 (Engineering Survey 3) # Modified from project_midpoint Example 1 library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 engr_surveyer(Northing_begin = Northing_begin, Easting_begin = Easting_begin, Northing_end = Northing_end, Easting_end = Easting_end, units = "survey_ft", location = "TN", output = "simple", engr_surv_choice = "project_midpoint")
The Darcy friction factor (f) is used in the "Darcy equation (also known as the Weisbach equation or Darcy-Weisbach equation)" to determine the "frictional energy loss for fluids" experiencing either laminar or turbulent flow (which is based on the Reynolds number). [Reference: Lindeburg Manual]
f1(Re)f1(Re)
Re |
numeric vector that contains the Reynolds number (dimensionless) |
Calculating the Darcy friction factor (f) for pipes
Please consult the references for the equations:
f1 - laminar flow equation (References: Lindeburg Manual and Zeghadnia) f2 - Moody equation (References: Genić and Zeghadnia) f3 - Romeo, et. al. equation (References: Genić and Zeghadnia) f4 - Žarko Ćojbašića and Dejan Brkić equation (Reference: Zeghadnia) f5 - Colebrook-White equation (References: Genić and Praks) f6 - Swamee-Jaine equation (References: Genić and Zeghadnia) f7 - Zigrang-Sylvester equation (References: Genić and Zeghadnia) f8 - Vatankhah equation (Reference: Zeghadnia)
the dimensionless Darcy friction factor (f) as a numeric vector
Irucka Embry
Steven C. Chapra, Applied Numerical Methods with MATLAB for Engineers and Scientists, Second Edition, Boston, Massachusetts: McGraw-Hill, 2008, pages 157-161.
Didier Clamond, "Efficient resolution of the Colebrook equation", Ind. Eng. Chem. Res., 2009, 48 (7), pages 3665-3671, https://arxiv.org/abs/0810.5564 and https://math.univ-cotedazur.fr/~didierc/DidPublis/ICR_2009.pdf
Srbislav Genić, Ivan Arandjelović, Petar Kolendić, Marko Jarić, Nikola Budimir, and Vojislav Genić, "A Review of Explicit Approximations of Colebrook's Equation", FME (Faculty of Mechanical Engineering, Belgrade) Transactions, 2011, 39, pages 67-71, https://www.mas.bg.ac.rs/_media/istrazivanje/fme/vol39/2/04_mjaric.pdf
Michael R. Lindeburg, PE, Civil Engineering Reference Manual for the PE Exam, Twelfth Edition, Belmont, California: Professional Publications, Inc., 2011, pages 17-5 - 17-7.
Michael R. Lindeburg, PE, Practice Problems for the Civil Engineering PE Exam: A Companion to the "Civil Engineering Reference Manual", Twelfth Edition, Belmont, California: Professional Publications, Inc., 2011, pages 17-1 and 17-8 - 17-9.
Pavel Praks and Dejan Brkić, "Advanced Iterative Procedures for Solving the Implicit Colebrook Equation for Fluid Flow Friction", Advances in Civil Engineering, Volume 2018, Article ID 5451034, 18 pages, https://onlinelibrary.wiley.com/doi/10.1155/2018/5451034
Lotfi Zeghadnia, Jean Loup Robert, and Bachir Achour, "Explicit solutions for turbulent flow friction factor: A review, assessment and approaches classification", Ain Shams Engineering Journal, March 2019, Volume 10, Issue 1, pages 243-252, https://www.sciencedirect.com/science/article/pii/S2090447919300176
Re1, Re2, Re3, and Re4 for the Reynolds number and colebrook
for an accurate representation of the Colebrook-White equation
library(iemisc) # Examples f1(200) f1(1999)library(iemisc) # Examples f1(200) f1(1999)
Moody Equation
f2(eps, Re, D = NULL)f2(eps, Re, D = NULL)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f3, f4, f5, f6, f7, f8
Romeo, et. al. Equation
f3(eps, Re, D = NULL, x0 = NULL)f3(eps, Re, D = NULL, x0 = NULL)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
x0 |
numeric vector that contains the starting value for pracma's newtonRaphson function |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f2, f4, f5, f6, f7, f8 and newtonRaphson for x0
Žarko Ćojbašića and Dejan Brkić Equation
f4(eps, Re, D, x0 = NULL)f4(eps, Re, D, x0 = NULL)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
x0 |
numeric vector that contains the starting value for pracma's newtonRaphson function |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f2, f3, f5, f6, f7, f8 and newtonRaphson for x0
Colebrook-White Equation
f5(eps, D = NULL, Re, x0 = NULL)f5(eps, D = NULL, Re, x0 = NULL)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
x0 |
numeric vector that contains the starting value for pracma's newtonRaphson function |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f2, f3, f4, f6, f7, f8 and newtonRaphson for x0
Swamee-Jaine Equation
f6(eps, D = NULL, Re, x0 = NULL)f6(eps, D = NULL, Re, x0 = NULL)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
x0 |
numeric vector that contains the starting value for pracma's newtonRaphson function |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f2, f3, f4, f5, f7, f8
Zigrang-Sylvester Equation
f7(eps, D = NULL, Re, x0 = NULL)f7(eps, D = NULL, Re, x0 = NULL)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
x0 |
numeric vector that contains the starting value for pracma's newtonRaphson function |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f2, f3, f4, f5, f6, f8 and newtonRaphson for x0
Vatankhah Equation
f8(eps, D, Re)f8(eps, D, Re)
eps |
numeric vector that contains the specific roughness for the pipe material (m or ft) |
D |
numeric vector that contains the inner diameters of the pipe (m or ft) |
Re |
numeric vector that contains the Reynolds number (dimensionless) |
the dimensionless Darcy friction factor (f) as a numeric vector
Note: Please refer to iemisc: Calculating the Friction Loss Examples vignette for the examples
Irucka Embry
f1 for the additional useful information, f2, f3, f4, f5, f6, f7
Compute F given A
FgivenA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) FA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )FgivenA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) FA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
A |
numeric vector that contains the annual value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
F is expressed as
the "future equivalent"
the "uniform series amount (occurs at the end of each interest period)"
the "effective interest rate per interest period"
the "number of interest periods"
FgivenA numeric vector that contains the future value(s) rounded to 2 decimal places
FA data.frame of both n (0 to n) and the resulting future values rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 131-132, 142, 164.
library(iemisc) # Example 4-7 from the Reference text (pages 131-132) FgivenA(23000, 40, 6, "annual") # the interest rate is 6\% FA(23000, 40, 6, "annual") # the interest rate is 6\%library(iemisc) # Example 4-7 from the Reference text (pages 131-132) FgivenA(23000, 40, 6, "annual") # the interest rate is 6\% FA(23000, 40, 6, "annual") # the interest rate is 6\%
Compute F given A with interest compounded continuously
FgivenAcont(A, n, r)FgivenAcont(A, n, r)
A |
numeric vector that contains the annual value(s) |
n |
numeric vector that contains the period value(s) |
r |
numeric vector that contains the continuously compounded nominal annual interest rate(s) as a percent |
F is expressed as
the "future equivalent"
the "annual equivalent amount (occurs at the end of each year)"
the "nominal annual interest rate, compounded continuously"
the "number of periods (years)"
FgivenAcont numeric vector that contains the future value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 169.
library(iemisc) FgivenAcont(2100, 13, 7) # the interest rate is 7%library(iemisc) FgivenAcont(2100, 13, 7) # the interest rate is 7%
Compute F given P
FgivenP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) FP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )FgivenP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) FP( P, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
F is expressed as
the "future equivalent"
the "present equivalent"
the "effective interest rate per interest period"
the "number of interest periods"
FgivenP numeric vector that contains the future value(s) rounded to 2 decimal places
FP data.frame of both n (0 to n) and the resulting future values rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 124, 142, 164-166.
library(iemisc) # Example 4-3 from the Reference text (page 124) FgivenP(8000, 4, 10, frequency = "annual") # the interest rate is 10\% FP(8000, 4, 10, frequency = "annual") # the interest rate is 10\% FgivenP(P = c(1000, 340, 23), n = c(12, 1.3, 3), i = c(10, 2, 0.3), "annual") # is is 10\%, 2\%, and 0.3% # Can't use FP for this example # Example 4-29 from the Reference text (pages 165-166) FgivenP(100, 10, 6, "quarter") # the interest rate is 6\% per quarter FP(100, 10, 6, "quarter") # the interest rate is 6\% per quarterlibrary(iemisc) # Example 4-3 from the Reference text (page 124) FgivenP(8000, 4, 10, frequency = "annual") # the interest rate is 10\% FP(8000, 4, 10, frequency = "annual") # the interest rate is 10\% FgivenP(P = c(1000, 340, 23), n = c(12, 1.3, 3), i = c(10, 2, 0.3), "annual") # is is 10\%, 2\%, and 0.3% # Can't use FP for this example # Example 4-29 from the Reference text (pages 165-166) FgivenP(100, 10, 6, "quarter") # the interest rate is 6\% per quarter FP(100, 10, 6, "quarter") # the interest rate is 6\% per quarter
Compute F given P with interest compounded continuously
FgivenPcont(P, n, r)FgivenPcont(P, n, r)
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
r |
numeric vector that contains the continuously compounded nominal annual interest rate(s) as a percent |
F is expressed as
the "future equivalent"
the "present equivalent"
the "nominal annual interest rate, compounded continuously"
the "number of periods (years)"
FgivenPcont numeric vector that contains the future value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 169-170.
library(iemisc) # Example 4-33 from the Reference text (page 170) FgivenPcont(10000, 2, 5) # the interest rate is 5%library(iemisc) # Example 4-33 from the Reference text (page 170) FgivenPcont(10000, 2, 5) # the interest rate is 5%
This function computes the final or sales price using the discount percent and the original price.
final_price(discount_percent, original_price)final_price(discount_percent, original_price)
discount_percent |
numeric vector containing the discount price of the item. |
original_price |
numeric vector containing the original price of the item. |
a numeric vector with the final or sales price.
Irucka Embry
dplyr - How to calculate discount in R? - Stack Overflow question asked and edited by datazang on Oct 28, 2021. See https://stackoverflow.com/questions/69761676/how-to-calculate-discount-in-r.
discount and the discount_percent
# Examples library(iemisc) original_price <- 2.24 sales_price <- 2.00 final_price(discount_percent(original_price, sales_price), original_price)# Examples library(iemisc) original_price <- 2.24 sales_price <- 2.00 final_price(discount_percent(original_price, sales_price), original_price)
Converts a fraction or a mixed number to a decimal
frac_to_numeric(n)frac_to_numeric(n)
n |
character vector that contains the fraction or mixed number (can also include text, ex. inch, inches, etc. that will be removed from the vector) |
the numeric vector as a decimal
Irucka Embry
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.
Bill Venables, 2016-02-10, "Vulgar Fractions in R", fractional vignette, https://CRAN.R-project.org/package=fractional/vignettes/Vulgar_Fractions_in_R.html.
The Home Depot, 9 December 2022, "How to Read a Tape Measure", https://web.archive.org/web/20230706082811/https://www.homedepot.com/c/ab/how-to-read-a-tape-measure/9ba683603be9fa5395fab90e6f14546. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Wikimedia Foundation, Inc. Wikipedia, 29 December 2021, "Pi", https://en.wikipedia.org/wiki/Pi.
construction_measurement for the wrapper function and construction_fraction if you have a measurement in feet + inches
# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 -- Reference 1 library(iemisc) xx <- as.character(fractional::fractional(1:9 / 12)) try(frac_to_numeric(xx)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xx, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 2 library(iemisc) xi <- fracture::fracture((50:65) / 12) try(frac_to_numeric(xi)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xi, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 3 library(iemisc) xyy <- fracture::fracture((1:11) / 12) try(frac_to_numeric(xyy)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xyy, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 4 library(iemisc) xft <- as.character(MASS::fractions((1:70) / 12)) try(frac_to_numeric(xft)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xft, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 5 library(iemisc) pix <- "270/11" pi1 <- "22/7" # Reference 3 pi2 <- "355/113" # Reference 3 pi3 <- "5 1/2 inches" pi4 <- "0 ft 5 1/2 inches" frac_to_numeric(pix) frac_to_numeric(pi1) frac_to_numeric(pi2) frac_to_numeric(pi3) frac_to_numeric(pi4) # Example 6 # If you have a construction measurement that includes a dimension in feet, # such as 49 ft 7 5/8 in, don't use the frac_to_numeric function. Instead # use the construction_fraction function. library(iemisc) xxift <- "49 ft 7 5/8 in" construction_decimal(xxift, decimal = "traditional", output = "vector") # Example 7 -- Reference 2 truss_marks <- "19 3/16 inches" frac_to_numeric(truss_marks)# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 -- Reference 1 library(iemisc) xx <- as.character(fractional::fractional(1:9 / 12)) try(frac_to_numeric(xx)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xx, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 2 library(iemisc) xi <- fracture::fracture((50:65) / 12) try(frac_to_numeric(xi)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xi, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 3 library(iemisc) xyy <- fracture::fracture((1:11) / 12) try(frac_to_numeric(xyy)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xyy, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 4 library(iemisc) xft <- as.character(MASS::fractions((1:70) / 12)) try(frac_to_numeric(xft)) # Please note that there will be an error because this function is designed to # only process one fraction at a time. lapply(xft, frac_to_numeric) # Please note that this is the correct way to work with several fractions at once. # Example 5 library(iemisc) pix <- "270/11" pi1 <- "22/7" # Reference 3 pi2 <- "355/113" # Reference 3 pi3 <- "5 1/2 inches" pi4 <- "0 ft 5 1/2 inches" frac_to_numeric(pix) frac_to_numeric(pi1) frac_to_numeric(pi2) frac_to_numeric(pi3) frac_to_numeric(pi4) # Example 6 # If you have a construction measurement that includes a dimension in feet, # such as 49 ft 7 5/8 in, don't use the frac_to_numeric function. Instead # use the construction_fraction function. library(iemisc) xxift <- "49 ft 7 5/8 in" construction_decimal(xxift, decimal = "traditional", output = "vector") # Example 7 -- Reference 2 truss_marks <- "19 3/16 inches" frac_to_numeric(truss_marks)
"Compute the fractional differences (1 - L)^d * x where L denotes the lag- operator and d is greater than -1." Source: Eaton Page 853.
fractdiff(x, d)fractdiff(x, d)
x |
A numeric vector |
d |
A numeric scalar |
Return the fractional differences.
Note: Please refer to the iemisc: Examples from GNU Octave Rem, Mod, and fractdiff Compatible Functions vignette for an example
Irucka Embry, GNU Octave Developers (GNU Octave code)
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’.
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’.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. ‘https://docs.octave.org/octave.pdf’. Page 853.
This function computes the missing value in the ideal gas law equation: PV = nRT [The letters in the equation refer to Pressure, Volume, number of moles, R gas constant, and Temperature, respectively].
ideal_gas( gas_name = NULL, gas_formula = NULL, P = NULL, V = NULL, gas_mass = NULL, gas_mole_mass = NULL, moles = NULL, R = NULL, Temp = NULL, Runit = NULL, Punit = c("atm", "mmHg", "Torr", "Pa", "kPa", "bar", "mb", "psi", "inH2O"), Vunit = c("L", "mL", "cubic meters", "cubic inches", "cubic feet", "cubic yards", "cubic centimeters", "cubic millimeters", "cubic kilometers"), massunit = c("Mg", "kg", "mg", "g", "slug", "lbm"), molesunit = c("mol", "lbmol"), Tempunit = c("degree_C", "degree_F", "degree_R", "Kelvin"), output = c("list", "data.table") )ideal_gas( gas_name = NULL, gas_formula = NULL, P = NULL, V = NULL, gas_mass = NULL, gas_mole_mass = NULL, moles = NULL, R = NULL, Temp = NULL, Runit = NULL, Punit = c("atm", "mmHg", "Torr", "Pa", "kPa", "bar", "mb", "psi", "inH2O"), Vunit = c("L", "mL", "cubic meters", "cubic inches", "cubic feet", "cubic yards", "cubic centimeters", "cubic millimeters", "cubic kilometers"), massunit = c("Mg", "kg", "mg", "g", "slug", "lbm"), molesunit = c("mol", "lbmol"), Tempunit = c("degree_C", "degree_F", "degree_R", "Kelvin"), output = c("list", "data.table") )
gas_name |
character vector that contains the name of the gas, if known. |
gas_formula |
character vector that contains the (simplified) chemical formula of the gas, if known. |
P |
numeric vector that contains the pressure, if known. |
V |
numeric vector that contains the volume, if known. |
gas_mass |
numeric vector that contains mass of the gas, if known. |
gas_mole_mass |
numeric vector that contains the molecular weight of the gas, if known. |
moles |
numeric vector that contains the number of moles of the gas, if known. |
R |
numeric vector that contains the gas constant, if known. If the R gas constant is not supplied, the default value of 0.08205736608096 L * atm * K^-1 * mol^-1 will be used. |
Temp |
numeric vector that contains the temperature, if known. |
Punit |
character vector that contains the pressure unit (the possible values are: atm, mmHg, Torr, Pa, kPa, bar, mb, psi, inH2O). If the pressure is not already in atm, it will be converted to atm. |
Vunit |
character vector that contains the volume unit (the possible values are: L, mL, cubic meters, cubic inches, cubic feet, cubic yards, cubic centimeters, cubic millimeters, cubic kilometers). If the volume is not already in L, it will be converted to L. |
massunit |
character vector that contains the mass unit (the possible values are: Mg, kg, mg, g, slug, lbm). If the mass is not already in g, it will be converted to g. |
molesunit |
character vector that contains the moles unit (the possible values are: mol, lbmol). If the moles is not already in mol, it will be converted to mol. |
Tempunit |
character vector that contains the temperature unit (the possible values are: degree_C, degree_F, degree_R, Kelvin). If the temperature is not already in Kelvin, it will be converted to Kelvin. |
output |
character vector that contains the output type, either it will
be a |
the P (Pressure), V (Volume), n (number of moles), R (gas constant),
Temp (Temperature), gas_name, and rho (density) as a list.
Alternatively, Pressure, Volume, moles, Mass, R constant, Temperature,
Gas Name, Gas Formula, and Density along with the associated units can
be returned in a data.table.
This function uses gases_plainer. If the chemical formula and/or the
chemical name is not included in that data set already, you will need to
provide the molecular weight for the gas. Please refer to the Example 4.
Irucka Embry
Chemistry LibreTexts. "Beginning Chemistry" By Theodore Chan at Fullerton College, "8.6: The Ideal Gas Law and Some Applications", https://chem.libretexts.org/Courses/Fullerton_College/Beginning_Chemistry_(Chan)/08%3A_Gases/8.06%3A_The_Ideal_Gas_Law_and_Some_Applications.
Chemistry LibreTexts. OT - PDX - Metro: General Chemistry I, "7.3.1: Practice Problems- Applications of the Ideal Gas Law", https://chem.libretexts.org/Courses/Oregon_Tech_PortlandMetro_Campus/OT_-_PDX_-_Metro%3A_General_Chemistry_I/07%3A_Ideal_Gas_Behavior/7.03%3A_Applications_of_the_Ideal_Gas_Law_and_Partial_Pressures/7.3.01%3A_Practice_Problems-_Applications_of_the_Ideal_Gas_Law.
Chemistry LibreTexts. Physical & Theoretical Chemistry: Supplemental Modules (Physical and Theoretical Chemistry), "The Ideal Gas Law", https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Physical_Properties_of_Matter/States_of_Matter/Properties_of_Gases/Gas_Laws/The_Ideal_Gas_Law.
Wikimedia Foundation, Inc. Wikipedia, 31 January 2025, "Pressure", https://en.wikipedia.org/wiki/Pressure.
ideal_gas_generic for the generic ideal gas calculator (no named gases nor gas formula)
# Example 1 from Example 2 of Reference 3 library(iemisc) ideal_gas(gas_name = "neon", P = 256, gas_mass = 5.0, Temp = 35, Punit = "mmHg", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list") # Example 2 modified from Example 2 of Reference 3 library(iemisc) ideal_gas(gas_name = "tetrafluoroethene", P = 256, gas_mass = 5.0, Temp = 35, Punit = "mmHg", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "data.table") # Example 3 from example Problem 7.3.1.1 of Reference 2 library(iemisc) ideal_gas(gas_formula = "N2O", P = 113.0, gas_mass = 5.0, Temp = 325, Punit = "kPa", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "Kelvin", output = "list") # Example 4 modified from Problem 7.3.1.2 of Reference 2 install.load::load_package("iemisc", "CHNOSZ") # As Freon 12 (CF2Cl2) is not in the gases_plainer data set from iemiscdata, # the gas molecular weight will be calculated first. gas_formula <- "CF2Cl2" gas_mole_mass <- mass(gas_formula) ideal_gas(gas_formula = gas_formula, gas_mole_mass = gas_mole_mass, P = 0.954, Temp = 30.0, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list") # Example 5 from Example 8.6.1 of Reference 1 library(iemisc) ideal_gas(gas_formula = "Ar", P = 1.21, Temp = 34, moles = 4.22, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list") ideal_gas(gas_formula = "Ar", P = 1.21, Temp = 34, moles = 4.22, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "data.table") # Example 6 from Example 4 of Reference 3 library(iemisc) ideal_gas(gas_formula = "N2", P = 248.0, Temp = 18, Punit = "Torr", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "data.table")# Example 1 from Example 2 of Reference 3 library(iemisc) ideal_gas(gas_name = "neon", P = 256, gas_mass = 5.0, Temp = 35, Punit = "mmHg", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list") # Example 2 modified from Example 2 of Reference 3 library(iemisc) ideal_gas(gas_name = "tetrafluoroethene", P = 256, gas_mass = 5.0, Temp = 35, Punit = "mmHg", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "data.table") # Example 3 from example Problem 7.3.1.1 of Reference 2 library(iemisc) ideal_gas(gas_formula = "N2O", P = 113.0, gas_mass = 5.0, Temp = 325, Punit = "kPa", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "Kelvin", output = "list") # Example 4 modified from Problem 7.3.1.2 of Reference 2 install.load::load_package("iemisc", "CHNOSZ") # As Freon 12 (CF2Cl2) is not in the gases_plainer data set from iemiscdata, # the gas molecular weight will be calculated first. gas_formula <- "CF2Cl2" gas_mole_mass <- mass(gas_formula) ideal_gas(gas_formula = gas_formula, gas_mole_mass = gas_mole_mass, P = 0.954, Temp = 30.0, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list") # Example 5 from Example 8.6.1 of Reference 1 library(iemisc) ideal_gas(gas_formula = "Ar", P = 1.21, Temp = 34, moles = 4.22, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list") ideal_gas(gas_formula = "Ar", P = 1.21, Temp = 34, moles = 4.22, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "data.table") # Example 6 from Example 4 of Reference 3 library(iemisc) ideal_gas(gas_formula = "N2", P = 248.0, Temp = 18, Punit = "Torr", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "data.table")
This function computes the missing value in the ideal gas law equation: PV = nRT [The letters in the equation refer to Pressure, Volume, number of moles, R gas constant, and Temperature, respectively]. This is for gases with no gas name or gas formula only.
ideal_gas_generic( P = NULL, V = NULL, gas_mass = NULL, moles = NULL, R = NULL, Runit = NULL, Temp = NULL, Punit = c("atm", "mmHg", "Torr", "Pa", "kPa", "bar", "mb", "psi", "inH2O"), Vunit = c("L", "mL", "cubic meters", "cubic inches", "cubic feet", "cubic yards", "cubic centimeters", "cubic millimeters", "cubic kilometers"), massunit = c("Mg", "kg", "mg", "g", "slug", "lbm"), molesunit = c("mol", "lbmol"), Tempunit = c("degree_C", "degree_F", "degree_R", "Kelvin"), output = c("list", "data.table") )ideal_gas_generic( P = NULL, V = NULL, gas_mass = NULL, moles = NULL, R = NULL, Runit = NULL, Temp = NULL, Punit = c("atm", "mmHg", "Torr", "Pa", "kPa", "bar", "mb", "psi", "inH2O"), Vunit = c("L", "mL", "cubic meters", "cubic inches", "cubic feet", "cubic yards", "cubic centimeters", "cubic millimeters", "cubic kilometers"), massunit = c("Mg", "kg", "mg", "g", "slug", "lbm"), molesunit = c("mol", "lbmol"), Tempunit = c("degree_C", "degree_F", "degree_R", "Kelvin"), output = c("list", "data.table") )
P |
numeric vector that contains the pressure, if known. |
V |
numeric vector that contains the volume, if known. |
gas_mass |
numeric vector that contains mass of the gas, if known. |
moles |
numeric vector that contains the number of moles of the gas, if known. |
R |
numeric vector that contains the gas constant, if known. If the R gas constant is not supplied, the default value of 0.08205736608096 L * atm * K^-1 * mol^-1 will be used. |
Temp |
numeric vector that contains the temperature, if known. |
Punit |
character vector that contains the pressure unit (the possible values are: atm, mmHg, Torr, Pa, kPa, bar, mb, psi, inH2O). If the pressure is not already in atm, it will be converted to atm. |
Vunit |
character vector that contains the volume unit (the possible values are: L, mL, cubic meters, cubic inches, cubic feet, cubic yards, cubic centimeters, cubic millimeters, cubic kilometers). If the volume is not already in L, it will be converted to L. |
massunit |
character vector that contains the mass unit (the possible values are: Mg, kg, mg, g, slug, lbm). If the mass is not already in g, it will be converted to g. |
molesunit |
character vector that contains the moles unit (the possible values are: mol, lbmol). If the moles is not already in mol, it will be converted to mol. |
Tempunit |
character vector that contains the temperature unit (the possible values are: degree_C, degree_F, degree_R, Kelvin). If the temperature is not already in Kelvin, it will be converted to Kelvin. |
output |
character vector that contains the output type, either it will
be a |
the P (Pressure), V (Volume), n (number of moles), R (gas constant),
Temp (Temperature), and rho (density) as a list.
Alternatively, Pressure, Volume, moles, Mass, R constant, Temperature,
and Density along with the associated units can be returned in a data.table.
Irucka Embry
Chemistry LibreTexts. Physical & Theoretical Chemistry: Supplemental Modules (Physical and Theoretical Chemistry), "The Ideal Gas Law", https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Physical_Properties_of_Matter/States_of_Matter/Properties_of_Gases/Gas_Laws/The_Ideal_Gas_Law.
Wikimedia Foundation, Inc. Wikipedia, 31 January 2025, "Pressure", https://en.wikipedia.org/wiki/Pressure.
ideal_gas for the ideal gas calculator
# Example from Example 3 of Reference 1 library(iemisc) ideal_gas_generic(P = 143.5, moles = 203, V = 25, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list")# Example from Example 3 of Reference 1 library(iemisc) ideal_gas_generic(P = 143.5, moles = 203, V = 25, Punit = "atm", Vunit = "L", massunit = "g", molesunit = "mol", Tempunit = "degree_C", output = "list")
Compute i given IC, n, and P
igivenICPn(P, IC, n = NULL, begin_event = NULL, end_event = NULL)igivenICPn(P, IC, n = NULL, begin_event = NULL, end_event = NULL)
P |
numeric vector that contains the principal value |
IC |
numeric vector that contains the total amount of interest charged |
n |
numeric vector that contains the number of years |
begin_event |
character vector that contains the start date |
end_event |
character vector that contains the end date |
i is expressed as
the interest rate
the total amount of interest charged
the principal amount of the loan
the number of years
i numeric vector that contains the simple interest rate as a percent rounded to 2 decimal places
Irucka Embry
TN Code § 47-14-102 (2021). 2021 Tennessee Code – Title 47 - Commercial Instruments and Transactions – Chapter 14 - Interest Rates Generally – § 47-14-102. Definitions. See https://law.justia.com/codes/tennessee/2021/title-47/chapter-14/section-47-14-102/.
# Example 1 library(iemisc) igivenICPn(P = 500, IC = 1000, n = 10) # Example 2 library(iemisc) igivenICPn(P = 500, IC = 1000, begin_event = "1 January 2020", end_event = "1 January 2030")# Example 1 library(iemisc) igivenICPn(P = 500, IC = 1000, n = 10) # Example 2 library(iemisc) igivenICPn(P = 500, IC = 1000, begin_event = "1 January 2020", end_event = "1 January 2030")
Compute i given F, n, and P
igivenPFn(P, F, n)igivenPFn(P, F, n)
P |
numeric vector that contains the present value(s) |
F |
numeric vector that contains the future value(s) |
n |
numeric vector that contains the period value(s) |
i is expressed as
the "effective interest rate per interest period"
the "future equivalent"
the "present equivalent"
the "number of interest periods"
i numeric vector that contains the effective interest rate as a percent rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 128-129, 142.
# Example for equation 4-6 from the Reference text (page 128) library(iemisc) igivenPFn(P = 500, F = 1000, n = 10)# Example for equation 4-6 from the Reference text (page 128) library(iemisc) igivenPFn(P = 500, F = 1000, n = 10)
Test for column vector that is compatible with GNU Octave/MATLAB.
iscolumn(x)iscolumn(x)
x |
An array (array, matrix, vector) |
"Return true if x is a column vector. A column vector is a 2-D array for which size (x) returns [N, 1] with non-negative N." Source: Eaton page 68.
Irucka Embry, Rik Wehbring (GNU Octave), Colin B. Macdonald (OctSymPy)
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 68.
library(iemisc) # Examples xxx <- ramify::mat("1, 2"); xxx iscolumn(xxx)library(iemisc) # Examples xxx <- ramify::mat("1, 2"); xxx iscolumn(xxx)
Test for row vector that is compatible with GNU Octave/MATLAB.
isrow(x)isrow(x)
x |
An array (array, matrix, vector) |
"Return true if x is a row vector. A row vector is a 2-D array for which size (x) returns [1, N] with non-negative N." Source: Eaton page 68.
Irucka Embry, Rik Wehbring (GNU Octave), Colin B. Macdonald (OctSymPy)
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 68.
library(iemisc) # Examples xx <- ramify::mat("1, 2"); xx isrow(xx)library(iemisc) # Examples xx <- ramify::mat("1, 2"); xx isrow(xx)
This function solves for the kinematic viscosity of water using only the water density and the dynamic viscosity.
kin_visc_water( rho, mu, rho_units = c("kg/m^3", "lbm/ft^3", "slug/ft^3"), mu_units = c("Pa*s or kg/m/s", "lbf*s/ft^2", "slug/ft/s") )kin_visc_water( rho, mu, rho_units = c("kg/m^3", "lbm/ft^3", "slug/ft^3"), mu_units = c("Pa*s or kg/m/s", "lbf*s/ft^2", "slug/ft/s") )
rho |
numeric vector that contains the water density |
mu |
numeric vector that contains the water dynamic viscosity |
rho_units |
character vector that contains the unit for the density of water [options are kg/m^3, lbm/ft^3, or slug/ft^3] |
mu_units |
character vector that contains the unit for the dynamic viscosity of water [options are Pa*s or kg/m/s, lbf*s/ft^2, or slug/ft/s] |
The simplified equation is expressed as
Water Kinematic Viscosity (m^2/s or ft^2/s)
Water Density (mass divided by volume), slug/ft^3
Water Dynamic viscosity, slug/ft/s
the kinematic viscosity as a numeric vector. The units are not returned.
Note: 1 lbf = 1 slug * 1 ft/sec^2, thus 1 slug = 1 lbf * sec^2 / 1 ft (Reference 2)
Thus, lbm/ft^3 = lbf*s^2/ft/ft^3
Irucka Embry
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.
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.
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 7-8.
Professor S.A. Kinnas, Commonly used units in CE319F (Elementary Fluid Mechanics), The University of Texas at Austin Department of Civil, Architectural and Environmental Engineering, https://www.caee.utexas.edu/prof/kinnas/319LAB/notes13/units_ce319f_kinnas.pdf.
# Example 1 # See Source 1 and Source 2 library(iemisc) try(kin_visc_water(mu = 34, rho = 0, rho_units = "kg/m^3", mu_units = "Pa*s or kg/m/s")) # Example 2 (from the Reference) install.load::load_package("iemisc", "units") import::from(fpCompare, "%==%") # For water at 68 F (20 C), mu = 2.09 * 10 ^ -8 slug/ft/s and rho = 1.937 slug/ft^3 kin_visc_water(mu = 2.09 * 10 ^ -8, rho = 1.937, rho_units = "slug/ft^3", mu_units = "slug/ft/s") # convert the units rho <- set_units(1.937, slug/ft^3) mu <- set_units(2.09 * 10 ^ -8, slug/ft/s) mu1 <- set_units(mu, kg/m/s) rho1 <- set_units(rho, "kg/m^3") kin_visc_water(mu = mu1, rho = rho1, rho_units = "kg/m^3", mu_units = "Pa*s or kg/m/s") mu2 <- set_units(mu, lbf*s/ft^2) rho2 <- set_units(rho, lb/ft^3) kin_visc_water(mu = mu2, rho = rho2, rho_units = "lbm/ft^3", mu_units = "lbf*s/ft^2") # compare the results of part 1 and part 3 (they should be equivalent) kin_visc_water(mu = 2.09 * 10 ^ -8, rho = 1.937, rho_units = "slug/ft^3", mu_units = "slug/ft/s") %==% kin_visc_water(mu = mu2, rho = rho2, rho_units = "lbm/ft^3", mu_units = "lbf*s/ft^2") # Example 2 - Example from the hydraulics package install.load::load_package("iemisc", "units") import::from(fpCompare, "%==%") nu <- hydraulics::kvisc(T = 55, units = "Eng", ret_units = TRUE); nu nus <- hydraulics::dvisc(T = 55, units = "Eng", ret_units = TRUE) / hydraulics::dens(T = 55, units = "Eng", ret_units = TRUE); nus # compare the results of nu and nus (they should be equivalent) drop_units(nu) %==% drop_units(nus) nu2 <- dyn_visc_water(Temp = 55, units = "Eng", Eng_units = "lbf*s/ft^2") / density_water(Temp = 55, units = "Eng", Eng_units = "slug/ft^3"); nu2 nus2 <- kin_visc_water(mu = dyn_visc_water(Temp = 55, units = "Eng", Eng_units = "lbf*s/ft^2"), rho = density_water(Temp = 55, units = "Eng", Eng_units = "slug/ft^3"), rho_units = "lbm/ft^3", mu_units = "lbf*s/ft^2"); nus2 # compare the results of nu2 and nus2 (they should be equivalent) nu2 %==% nus2# Example 1 # See Source 1 and Source 2 library(iemisc) try(kin_visc_water(mu = 34, rho = 0, rho_units = "kg/m^3", mu_units = "Pa*s or kg/m/s")) # Example 2 (from the Reference) install.load::load_package("iemisc", "units") import::from(fpCompare, "%==%") # For water at 68 F (20 C), mu = 2.09 * 10 ^ -8 slug/ft/s and rho = 1.937 slug/ft^3 kin_visc_water(mu = 2.09 * 10 ^ -8, rho = 1.937, rho_units = "slug/ft^3", mu_units = "slug/ft/s") # convert the units rho <- set_units(1.937, slug/ft^3) mu <- set_units(2.09 * 10 ^ -8, slug/ft/s) mu1 <- set_units(mu, kg/m/s) rho1 <- set_units(rho, "kg/m^3") kin_visc_water(mu = mu1, rho = rho1, rho_units = "kg/m^3", mu_units = "Pa*s or kg/m/s") mu2 <- set_units(mu, lbf*s/ft^2) rho2 <- set_units(rho, lb/ft^3) kin_visc_water(mu = mu2, rho = rho2, rho_units = "lbm/ft^3", mu_units = "lbf*s/ft^2") # compare the results of part 1 and part 3 (they should be equivalent) kin_visc_water(mu = 2.09 * 10 ^ -8, rho = 1.937, rho_units = "slug/ft^3", mu_units = "slug/ft/s") %==% kin_visc_water(mu = mu2, rho = rho2, rho_units = "lbm/ft^3", mu_units = "lbf*s/ft^2") # Example 2 - Example from the hydraulics package install.load::load_package("iemisc", "units") import::from(fpCompare, "%==%") nu <- hydraulics::kvisc(T = 55, units = "Eng", ret_units = TRUE); nu nus <- hydraulics::dvisc(T = 55, units = "Eng", ret_units = TRUE) / hydraulics::dens(T = 55, units = "Eng", ret_units = TRUE); nus # compare the results of nu and nus (they should be equivalent) drop_units(nu) %==% drop_units(nus) nu2 <- dyn_visc_water(Temp = 55, units = "Eng", Eng_units = "lbf*s/ft^2") / density_water(Temp = 55, units = "Eng", Eng_units = "slug/ft^3"); nu2 nus2 <- kin_visc_water(mu = dyn_visc_water(Temp = 55, units = "Eng", Eng_units = "lbf*s/ft^2"), rho = density_water(Temp = 55, units = "Eng", Eng_units = "slug/ft^3"), rho_units = "lbm/ft^3", mu_units = "lbf*s/ft^2"); nus2 # compare the results of nu2 and nus2 (they should be equivalent) nu2 %==% nus2
Using the provided latitude/longitude coordinates (as character or numeric vectors), this function determines whether the location is within an United States of America (USA) state/commonwealth, Puerto Rico, or the U.S. Virgin Islands
lat_long2state(latitude, longitude)lat_long2state(latitude, longitude)
latitude |
numeric vector (or character vector with numbers only) that contains the latitude as a decimal degree |
longitude |
numeric vector (or character vector with numbers only) that contains the longitude as a decimal degree |
the location name as a character vector (United States of America (USA) state/commonwealth, Puerto Rico, or the U.S. Virgin Islands
Irucka Embry, Josh O'Brien (Stack Overflow R code)
Latitude Longitude Coordinates to State Code in R - Stack Overflow answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.
# Example 1 library(iemisc) lat_long2state(latitude = c(36.3684553, 40), longitude = c(-82.1796880, -89)) lat_long2state(latitude = "36.3684553", longitude = "-82.1796880") # Example 2 # Test the function using points in Wisconsin and Oregon (From Source 1) library(iemisc) x = c(-90, -120); y = c(44, 44) lat_long2state(latitude = y, longitude = x)# Example 1 library(iemisc) lat_long2state(latitude = c(36.3684553, 40), longitude = c(-82.1796880, -89)) lat_long2state(latitude = "36.3684553", longitude = "-82.1796880") # Example 2 # Test the function using points in Wisconsin and Oregon (From Source 1) library(iemisc) x = c(-90, -120); y = c(44, 44) lat_long2state(latitude = y, longitude = x)
Takes latitude/longitude coordinates (as numeric vector or a character vector coercible to a numeric vector) and transforms them into their respective UTM Easting and Northing coordinates (with units of US Survey foot, foot, or meters) & UTM Zone.
lat_long2utm( latitude, longitude, units = c("us-ft", "ft", "m"), output = c("basic", "table") )lat_long2utm( latitude, longitude, units = c("us-ft", "ft", "m"), output = c("basic", "table") )
latitude |
numeric vector (or character vector with numbers only) that contains the latitude as a decimal degree |
longitude |
numeric vector (or character vector with numbers only) that contains the longitude as a decimal degree |
units |
character vector that contains the system of units (options are
|
output |
character vector that contains basic for the default result
using a |
the UTM zone along with the UTM Easting and Northing coordinates (in the requested unit) as either a list or a data.table
Remember: Latitude coordinates signify North (N) or South (S) while longitude coordinates signify East (E) and West (W). It is customary to denote West longitude coordinates and South latitude coordinates as negative (-).
Stack Overflow user contributions are "distributed under the terms of CC BY-SA 3.0" "from 2011-04-08 up to but not including 2018-05-02 (UTC)". [Stack Overflow Reference] I have decided to make my adaptions to the Stack Overflow user contributions as CC BY-SA 4.0 thereby enabling me to license my adaptions to the aforementioned code as GPLv3. [Creative Commons References] Stack Overflow user contributions are "distributed under the terms of CC BY-SA 4.0" "on or after 2018-05-02 (UTC)". [Stack Overflow Reference] Thus, my adaptions of the Stack Overflow code can be released as GPLv3. [Creative Commons References]
Irucka Embry, Teodor Ciuraru (Latitude/Longitude to UTM conversion code), and Josh O'Brien (Latitude/Longitude to UTM conversion code)
Stack Overflow: r - Converting latitude and longitude points to UTM answered and edited by Teodor Ciuraru on Feb 17 2018. See https://stakoverflow.com/questions/18639967/converting-latitude-and-longitude-points-to-utm.
Stack Overflow: r - Converting latitude and longitude points to UTM answered by Josh O'Brien on Sep 5 2013 and edited by Josh O'Brien on Feb 21 2014. See https://stakoverflow.com/questions/18639967/converting-latitude-and-longitude-points-to-utm.
Stack Overflow: r - data.table alternative for dplyr mutate? answered by Arun on Aug 30 2015. See https://stackoverflow.com/questions/29583665/data-table-alternative-for-dplyr-mutate.
Stack Overflow: database design - What is the maximum length of latitude and longitude? answered by JasonM1 on May 24 2013 and edited by JasonM1 on Jul 16 2019. See https://stackoverflow.com/questions/15965166/what-is-the-maximum-length-of-latitude-and-longitude.
Stack Overflow: r - How to not run an example using roxygen2? 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.
Stack Overflow: devtools - Issues in R package after CRAN asked to replace dontrun by donttest 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.
Stack Overflow: Latitude Longitude Coordinates to State Code in R answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.
MapTools, 29 May 2016, "More details about UTM grid zones", https://www.maptools.com/tutorials/grid_zone_details.
Wikimedia Foundation, Inc. Wikipedia, 11 August 2019, "Geographic coordinate system", https://en.wikipedia.org/wiki/Geographic_coordinate_system.
PROJ 6.2.0 documentation, 28 Oct 2019, "Cartographic projection", https://proj.org/usage/projections.html.
Wikimedia Foundation, Inc. Wikibooks, 19 August 2018, "PROJ.4", https://en.wikibooks.org/wiki/PROJ.4.
Sophia Palombo, "Military Grid Reference System (MGRS)", May 3, 2021, https://storymaps.arcgis.com/stories/842edf2b4381438b9a4edefed124775b.
MGRS Data – Military Grid Reference System (MGRS) Data Downloads, "MGRS", https://www.mgrs-data.org/data/documents/nga_mgrs_doc.pdf.
Tennessee Department of Transportation Design Division, Tennessee Department of Transportation Tennessee Geodetic Reference Network (TGRN) Reference Manual Second Edition Issued, page ix, https://www.tn.gov/content/dam/tn/tdot/documents/TgrnComposite.pdf.
LatLong.net, "Lat Long to UTM Converter", https://www.latlong.net/lat-long-utm.html.
NOAA’s National Geodetic Survey (NGS), "NGS Coordinate Conversion and Transformation Tool (NCAT)", https://www.ngs.noaa.gov/NCAT/.
Creative Commons. Weblog Archives, October 8, 2015, "CC BY-SA 4.0 now one-way compatible with GPLv3: The declaration increases interoperability of the commons for games, hardware designs, and more" Posted by mike, https://creativecommons.org/2015/10/08/cc-by-sa-4-0-now-one-way-compatible-with-gplv3/.
Stack Overflow. Help Center, "What is the license for the content I post?", https://stackoverflow.com/help/licensing.
# Example 1 # Test location from TGRN Reference Manual with NCAT # using the 1983 (1995) DATUM # GPS 1 is the station name with these coordinates # latitude (North) = 36 22 6.43923 # longitude (West) = 82 10 46.87679 install.load::load_package("iemisc", "sp") lats <- as.numeric(char2dms("36d22'6.43923\"N")) # Value is not directly coercible to a numeric value lats longs <- as.numeric(char2dms("82d10'46.87679\"W")) # Value is not directly coercible to a numeric value longs latsc <- as.character(lats) latsc longsc <- as.character(longs) longsc lat_long2utm(latsc, longsc, units = "m", output = "basic") lat_long2utm(latsc, longsc, units = "m", output = "table") lat_long2utm(lats, longs, units = "m", output = "basic") lat_long2utm(lats, longs, units = "m", output = "table") # From https://www.ngs.noaa.gov/NCAT/ # Latitude: 36.3684553416667 # Longitude: -82.1796879972222 # UTM Northing (m): 4,025,462.877 # UTM Easting (m): 394,172.067 # USNG: 17SLA9417225462 # Example 2 # Test against Grid [Reference: National Geospatial-Intelligence Agency Office of Geomatics] library(iemisc) lat_long2utm("80", "-179", units = "m", output = "basic") # = 1X lat_long2utm("-80", "-179", units = "m", output = "basic") # = 1C # Example 3 # Test with world cities # See Source 5 and Source 6 install.load::load_package("iemisc", "maps", "rando", "utils", "data.table") import::from(sampler, rsamp) data(world.cities) # from maps set_n(200) # makes the example reproducible wc <- rsamp(world.cities, 2, over = 0, rep = FALSE) wc wcutm1 <- lat_long2utm(wc$lat[1], wc$long[1], units = "m", output = "table") wcutm1 wcutm2 <- lat_long2utm(wc$lat[2], wc$long[2], units = "m", output = "table") wcutm2 l <- list(wcutm1, wcutm2) ll <- rbindlist(l) wc_utm <- setDT(cbind(wc, ll)) wc_utm # Example 4 # Test with 2 Web sites library(iemisc) latlong1 <- lat_long2utm(6.32, 7.41, units = "m", output = "table") latlong1 latlong2 <- lat_long2utm(44.47, 19.81, units = "m", output = "table") latlong2 # Results from https://www.latlong.net/lat-long-utm.html # Latitude: 6.32 # Longitude: 7.41 # UTM Easting: 324118.76 # UTM Northing: 698846.97 # UTM Zone: 32N # Latitude: 44.47 # Longitude: 19.81 # UTM Easting: 405349.04 # UTM Northing: 4924765.48 # UTM Zone: 34T # Results from https://www.ngs.noaa.gov/NCAT/ # Latitude: 6.32 # Longitude: 7.41 # UTM Northing (m): 698,846.969 # UTM Easting (m): 324,118.758 # USNG: 32NLM2411898846 # Latitude: 44.47 # Longitude: 19.81 # UTM Northing (m): 4,924,765.484 # UTM Easting (m): 405,349.043 # USNG: 34TDQ0534924765# Example 1 # Test location from TGRN Reference Manual with NCAT # using the 1983 (1995) DATUM # GPS 1 is the station name with these coordinates # latitude (North) = 36 22 6.43923 # longitude (West) = 82 10 46.87679 install.load::load_package("iemisc", "sp") lats <- as.numeric(char2dms("36d22'6.43923\"N")) # Value is not directly coercible to a numeric value lats longs <- as.numeric(char2dms("82d10'46.87679\"W")) # Value is not directly coercible to a numeric value longs latsc <- as.character(lats) latsc longsc <- as.character(longs) longsc lat_long2utm(latsc, longsc, units = "m", output = "basic") lat_long2utm(latsc, longsc, units = "m", output = "table") lat_long2utm(lats, longs, units = "m", output = "basic") lat_long2utm(lats, longs, units = "m", output = "table") # From https://www.ngs.noaa.gov/NCAT/ # Latitude: 36.3684553416667 # Longitude: -82.1796879972222 # UTM Northing (m): 4,025,462.877 # UTM Easting (m): 394,172.067 # USNG: 17SLA9417225462 # Example 2 # Test against Grid [Reference: National Geospatial-Intelligence Agency Office of Geomatics] library(iemisc) lat_long2utm("80", "-179", units = "m", output = "basic") # = 1X lat_long2utm("-80", "-179", units = "m", output = "basic") # = 1C # Example 3 # Test with world cities # See Source 5 and Source 6 install.load::load_package("iemisc", "maps", "rando", "utils", "data.table") import::from(sampler, rsamp) data(world.cities) # from maps set_n(200) # makes the example reproducible wc <- rsamp(world.cities, 2, over = 0, rep = FALSE) wc wcutm1 <- lat_long2utm(wc$lat[1], wc$long[1], units = "m", output = "table") wcutm1 wcutm2 <- lat_long2utm(wc$lat[2], wc$long[2], units = "m", output = "table") wcutm2 l <- list(wcutm1, wcutm2) ll <- rbindlist(l) wc_utm <- setDT(cbind(wc, ll)) wc_utm # Example 4 # Test with 2 Web sites library(iemisc) latlong1 <- lat_long2utm(6.32, 7.41, units = "m", output = "table") latlong1 latlong2 <- lat_long2utm(44.47, 19.81, units = "m", output = "table") latlong2 # Results from https://www.latlong.net/lat-long-utm.html # Latitude: 6.32 # Longitude: 7.41 # UTM Easting: 324118.76 # UTM Northing: 698846.97 # UTM Zone: 32N # Latitude: 44.47 # Longitude: 19.81 # UTM Easting: 405349.04 # UTM Northing: 4924765.48 # UTM Zone: 34T # Results from https://www.ngs.noaa.gov/NCAT/ # Latitude: 6.32 # Longitude: 7.41 # UTM Northing (m): 698,846.969 # UTM Easting (m): 324,118.758 # USNG: 32NLM2411898846 # Latitude: 44.47 # Longitude: 19.81 # UTM Northing (m): 4,924,765.484 # UTM Easting (m): 405,349.043 # USNG: 34TDQ0534924765
Computes the pound force (weight) from the mass, if missing or the pound mass (mass) from the weight, if missing.
lb_mass_force(mass = NULL, weight = NULL)lb_mass_force(mass = NULL, weight = NULL)
mass |
numeric vector that contains the mass (lb mass only), if not missing |
weight |
numeric vector that contains the weight (lb force only), if not missing |
missing value (mass in lb mass or weight in lb force) as a numeric vector
Irucka Embry
# Examples library(iemisc) mass <- lb_mass_force(weight = 190) # weight = 190 lb force mass weight <- lb_mass_force(mass = mass) # mass = previously calculated mass weight# Examples library(iemisc) mass <- lb_mass_force(weight = 190) # weight = 190 lb force mass weight <- lb_mass_force(mass = mass) # mass = previously calculated mass weight
Obtain the length of R objects [arrays, matrices, and vectors (including
lists)] in a manner compatible with GNU Octave/MATLAB. Some documentation
from length.
length_octave(x)length_octave(x)
x |
An R object (array, matrix, vector) |
Return the length of the object x as an integer. "The length is 0
for empty objects, 1 for scalars (in R, a vector of length 1), and
the number of elements (in R, the length) for vectors. For matrix objects,
the length is the number of rows or columns, whichever is greater (this
odd definition is used for compatibility with MATLAB)." Source: Eaton.
Irucka Embry, Samit Basu (FreeMat)
Samit Basu (2002-2006). FreeMat v4.0, https://freemat.sourceforge.net/help/inspection_length.html.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 47.
library(iemisc) import::from(matlab, ones) # Example from pracma isempty object1 <- matrix(0, 1, 0) length_octave(object1)library(iemisc) import::from(matlab, ones) # Example from pracma isempty object1 <- matrix(0, 1, 0) length_octave(object1)
lookup - data.table
based hash table useful for large vector lookups.Hash Table/Dictionary Lookup
These functions were originally contained in "qdapTools" version 1.3.4
lookup - data.table
based hash table useful for large vector lookups.
lookupQT(terms, key.match, key.reassign = NULL, missing = NA)lookupQT(terms, key.match, key.reassign = NULL, missing = NA)
terms |
A vector of terms to undergo a lookup. |
key.match |
Takes one of the following: (1) a two column data.frame of a match key and reassignment column, (2) a named list of vectors (Note: if data.frame or named list supplied no key reassign needed) or (3) a single vector match key. |
key.reassign |
A single reassignment vector supplied if key.match is not a two column data.frame/named list. |
missing |
Value to assign to terms not matching the key.match. If set
to |
Outputs A new vector with reassigned values.
Tyler Rinker ('qdapTools' package version 1.3.4)
Wrapper function to the Manningcirc, Manningpara, Manningrect, Manningtri, Manningtrap, Manningtrap_critical functions. This function solves for one missing variable in the Gauckler-Manning-Strickler equation for a circular, parabolic, rectangular, triangular, or trapezoidal cross-section and uniform flow.
Manning( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, b = NULL, B1 = NULL, y1 = NULL, d = NULL, Temp = NULL, cross_section = c("circular", "parabolic", "rectangular", "triangular", "trapezoidal_normal", "trapezoidal_critical"), units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), critical = c("approximate", "accurate"), output = c("list", "data.table") )Manning( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, b = NULL, B1 = NULL, y1 = NULL, d = NULL, Temp = NULL, cross_section = c("circular", "parabolic", "rectangular", "triangular", "trapezoidal_normal", "trapezoidal_critical"), units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), critical = c("approximate", "accurate"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
m |
numeric vector that contains the "cross-sectional side slope of m:1 (horizontal:vertical)", if known. |
m1 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m1:V (horizontal:vertical)", if known. |
m2 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m2:V (horizontal:vertical)", if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
b |
numeric vector that contains the bottom width, if known. [Trapezoidal and Rectangular cross-section only] |
B1 |
numeric vector that contains the "bank-full width", if known. [Parabolic cross-section only] |
y1 |
numeric vector that contains the "bank-full depth", if known. [Parabolic cross-section only] |
d |
numeric vector that contains the diameter value (m or ft), if known. [Circular cross-section only] |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. Otherwise, the default value is 20 degrees Celsius (68 degrees Fahrenheit). |
cross_section |
character vector that contains the type of cross-section (circular, parabolic, rectangular, triangular, trapezoidal_normal, or trapezoidal_critical) |
units |
character vector that contains the system of units [options are
|
type |
character vector that contains the type of trapezoid (symmetrical
or non-symmetrical). The symmetrical trapezoid uses |
critical |
character vector that contains the type of critical parameters
calculations ( |
output |
character vector that contains the output type, either it will
be a |
the missing parameters and additional parameters as either a list or a
data.table. Please refer to the return sections of the cross-sections for more details.
Assumptions: uniform flow, prismatic channel, and surface water temperature of 20 degrees Celsius (68 degrees Fahrenheit) at atmospheric pressure
Note: Units must be consistent
Irucka Embry
r - How to pass alternative arguments through wrapper function? - Stack Overflow answered by G. Grothendieck on Oct 8, 2013 and edited by Ricardo Guerreiro on Dec 21, 2018. See https://stackoverflow.com/questions/19258574/how-to-pass-alternative-arguments-through-wrapper-function.
Manningtrap for a trapezoidal cross-section, Manningtri
for a triangular cross-section, Manningrect for a
rectangular cross-section, Manningpara for a parabolic
cross-section, and Manningcirc for a circular cross-section.
# Examples library(iemisc) # Modified Exercise 4.5 from Sturm (page 154) Manning(Q = 950, m = 2, Sf = 0.022, n = 0.023, units = "SI", output = "data.table", type = "symmetrical", cross_section = "triangular") # Q = 950 m^3/s, m = 2, Sf = 0.022 m/m, n = 0.023, units = SI units # This will solve for y since it is missing and y will be in m # Exercise 4.3 from Sturm (page 153) y <- Manning(Q = 12.0, B1 = 10, y1 = 2.0, Sf = 0.005, n = 0.05, units = "SI", output = "list", cross_section = "parabolic") # defines all list values within the object named y # Q = 12.0 m^3/s, B1 = 10 m, y1 = 2.0 m, Sf = 0.005 m/m, n = 0.05, units = SI units # This will solve for y since it is missing and y will be in m y$y # gives the value of y Manning(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", cross_section = "trapezoidal_normal", output = "data.table", type = "symmetrical") Manning(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", cross_section = "trapezoidal_critical", output = "data.table", critical = "accurate", type = "symmetrical") # Example 4.1 from Sturm (pages 124-125) Manningcircy(y_d = 0.8, d = 2, units = "Eng") # Note that Manningcircy, if required, must be evaluated on its own and not # through the Manning function ycirc <- Manningcircy(y_d = 0.8, d = 2, units = "Eng") # defines all list values within the object named ycirc ycirc$y # gives the value of y # Modified Exercise 4.5 from Sturm (page 154) install.load::load_package("iemisc", "units") import::from(fpCompare, "%==%") # create a numeric vector with the units of feet yeng <- set_units(ycirc$y, ft) # create a numeric vector to convert from feet to meters ysi <- yeng # create a numeric vector with the units of meters units(ysi) <- make_units(m) # create a numeric vector with the units of feet deng <- set_units(2, ft) # create a numeric vector to convert from feet to meters dsi <- deng # create a numeric vector with the units of meters units(dsi) <- make_units(m) Manning(Sf = 0.022, n = 0.023, y = drop_units(ysi), d = drop_units(dsi), units = "SI", output = "data.table", cross_section = "circular") # Sf = 0.022 m/m, n = 0.023, y = 0.48768 m, d = 0.6096 m, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s # test that y makes sense y_d <- 0.8; d <- 2 y_dd <- ycirc$y / d y_d %==% y_dd# Examples library(iemisc) # Modified Exercise 4.5 from Sturm (page 154) Manning(Q = 950, m = 2, Sf = 0.022, n = 0.023, units = "SI", output = "data.table", type = "symmetrical", cross_section = "triangular") # Q = 950 m^3/s, m = 2, Sf = 0.022 m/m, n = 0.023, units = SI units # This will solve for y since it is missing and y will be in m # Exercise 4.3 from Sturm (page 153) y <- Manning(Q = 12.0, B1 = 10, y1 = 2.0, Sf = 0.005, n = 0.05, units = "SI", output = "list", cross_section = "parabolic") # defines all list values within the object named y # Q = 12.0 m^3/s, B1 = 10 m, y1 = 2.0 m, Sf = 0.005 m/m, n = 0.05, units = SI units # This will solve for y since it is missing and y will be in m y$y # gives the value of y Manning(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", cross_section = "trapezoidal_normal", output = "data.table", type = "symmetrical") Manning(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", cross_section = "trapezoidal_critical", output = "data.table", critical = "accurate", type = "symmetrical") # Example 4.1 from Sturm (pages 124-125) Manningcircy(y_d = 0.8, d = 2, units = "Eng") # Note that Manningcircy, if required, must be evaluated on its own and not # through the Manning function ycirc <- Manningcircy(y_d = 0.8, d = 2, units = "Eng") # defines all list values within the object named ycirc ycirc$y # gives the value of y # Modified Exercise 4.5 from Sturm (page 154) install.load::load_package("iemisc", "units") import::from(fpCompare, "%==%") # create a numeric vector with the units of feet yeng <- set_units(ycirc$y, ft) # create a numeric vector to convert from feet to meters ysi <- yeng # create a numeric vector with the units of meters units(ysi) <- make_units(m) # create a numeric vector with the units of feet deng <- set_units(2, ft) # create a numeric vector to convert from feet to meters dsi <- deng # create a numeric vector with the units of meters units(dsi) <- make_units(m) Manning(Sf = 0.022, n = 0.023, y = drop_units(ysi), d = drop_units(dsi), units = "SI", output = "data.table", cross_section = "circular") # Sf = 0.022 m/m, n = 0.023, y = 0.48768 m, d = 0.6096 m, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s # test that y makes sense y_d <- 0.8; d <- 2 y_dd <- ycirc$y / d y_d %==% y_dd
Manningcirc and Manningcircy solve for a missing variable for a circular
cross-section. The uniroot function is used to obtain the
missing parameters.
The Manningcirc function solves for one missing variable in the Gauckler- Manning equation for a circular cross-section and uniform flow. The possible inputs are Q, n, Sf, y, and d. If y or d are not initially known, then Manningcircy can solve for y or d to use as input in the Manningcirc function.
Manningcirc( Q = NULL, n = NULL, Sf = NULL, y = NULL, d = NULL, Temp = NULL, units = c("SI", "Eng"), output = c("list", "data.table") )Manningcirc( Q = NULL, n = NULL, Sf = NULL, y = NULL, d = NULL, Temp = NULL, units = c("SI", "Eng"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
d |
numeric vector that contains the diameter value (m or ft), if known. |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. |
units |
character vector that contains the system of units [options are
|
output |
character vector that contains the output type, either it will
be a |
Circular cross-section using the Gauckler-Manning-Strickler equation
Gauckler-Manning-Strickler equation is expressed as
the velocity (m/s or ft/s)
Manning's roughness coefficient (dimensionless)
the hydraulic radius (m or ft)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
This equation is also expressed as
the discharge [m^3/s or ft^3/s (cfs)] is VA
Manning's roughness coefficient (dimensionless)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
Other important equations regarding the circular cross-section follow:
the hydraulic radius (m or ft)
the cross-sectional area (m^2 or ft^2)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the diameters of the cross-section (m or ft)
see the equation defining this parameters
see the equation defining this parameters
the flow depth (normal depth in this function) [m or ft]
the diameters of the cross-section (m or ft)
the initial diameters of the cross-section [m or ft]
the discharge [m^3/s or ft^3/s (cfs)] is VA
Manning's roughness coefficient (dimensionless)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
Note: This will only provide the initial conduit diameters, check the design considerations to determine your next steps.
the wetted perimeter of the channel (m or ft)
see the equation defining this parameters
the diameters of the cross-section (m or ft)
the top width of the channel (m or ft)
see the equation defining this parameters
the diameters of the cross-section (m or ft)
the hydraulic depth (m or ft)
the cross-sectional area (m^2 or ft^2)
the top width of the channel (m or ft)
the Section factor (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the Specific Energy (m or ft)
the discharge [m^3/s or ft^3/s (cfs)] is VA
gravitational acceleration (m/s^2 or ft/sec^2)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the Velocity Head (m or ft)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
A rough turbulent zone check is performed on the water flowing in the channel using the Reynolds number (Re). The Re equation follows:
Reynolds number (dimensionless)
density (kg/m^3 or slug/ft^3)
the hydraulic radius (m or ft)
the velocity (m/s or ft/s)
dynamic viscosity (* 10^-3 kg/m*s or * 10^-5 lb*s/ft^2)
A critical flow check is performed on the water flowing in the channel using the Froude number (Fr). The Fr equation follows:
the Froude number (dimensionless)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
the hydraulic depth (m or ft)
the missing parameters (Q, n, Sf, B1, y1, or y) & V (velocity),
Flow depth (y), Slope (Sf), A (area), P (wetted perimeters), R (hydraulic
radius), B (top width), D (hydraulic depth), y1 (Bank-full depth), B1
(Bank-full Width), Z (Section Factor), E (Specific Energy), K
(conveyance), Vel_Head (Velocity Head), Re (Reynolds number), Fr (Froude
number), taud (maximum shear stress), tau0 (average shear stress) as a list.
Alternatively, the Flow depth (y), Bank-full depth (y1), Flow area (A),
Wetted Perimeter (P), Top Width (B), Bank-full Width (B1), Hydraulic
Radius (R), Hydraulic Depth (D), Flow Mean Velocity (V), Flow Discharge
(Q), Manning's roughness coefficient (n), Slope (Sf), Temperature,
Absolute Temperature, Saturated Liquid Density, Absolute or Dynamic
Viscosity, Kinematic Viscosity, Froude number (Fr), Reynolds number (Re),
Section Factor (Z), conveyance (K), Specific Energy (E), Velocity Head
(Vel_Head), Maximum Shear Stress (taud), Average Shear Stress (tau0)
along with the associated units can be returned in a data.table.
Assumptions: uniform flow, prismatic channel, and surface water temperature of 20 degrees Celsius (68 degrees Fahrenheit) at atmospheric pressure
Note: Units must be consistent
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 2, 8, 36, 102, 120, 123-125, 153-154.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Gilberto E. Urroz, Utah State University Civil and Environmental Engineering - OCW, CEE6510 - Numerical Methods in Civil Engineering, Spring 2006 (2006). Course 3. "Solving selected equations and systems of equations in hydraulics using Matlab", August/September 2004, https://digitalcommons.usu.edu/ocw_cee/3/.
Tyler G. Hicks, P.E., Civil Engineering Formulas: Pocket Guide, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2002, pages 423, 425.
Wikimedia Foundation, Inc. Wikipedia, 26 November 2015, "Manning formula", https://en.wikipedia.org/wiki/Manning_formula.
John C. Crittenden, R. Rhodes Trussell, David W. Hand, Kerry J. Howe, George Tchobanoglous, MWH's Water Treatment: Principles and Design, Third Edition, Hoboken, New Jersey: John Wiley & Sons, Inc., 2012, pages 1861-1862.
Andrew Chadwick, John Morfett and Martin Borthwick, Hydraulics in Civil and Environmental Engineering, Fourth Edition, New York City, New York: Spon Press, Inc., 2004, page 133.
Robert L. Mott and Joseph A. Untener, Applied Fluid Mechanics, Seventh Edition, New York City, New York: Pearson, 2015, pages 376, 377-378, 392.
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 21, 40-41.
Gary P. Merkley, "BIE6300 - Irrigation & Conveyance Control Systems, Spring 2004", 2004, Biological and Irrigation Engineering - OCW. Course 2, https://digitalcommons.usu.edu/ocw_bie/2/.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Wikimedia Foundation, Inc. Wikipedia, 15 May 2019, "Conversion of units", https://en.wikipedia.org/wiki/Conversion_of_units.
Manningtrap for a trapezoidal cross-section, Manningrect for a
rectangular cross-section, Manningtri for a triangular cross-section,
Manningpara for a parabolic cross-section, and Manning for the wrapper function.
# Practice Problem 14.12 from Mott (page 392) install.load::load_package("iemisc", "iemiscdata") y <- Manningcircy(y_d = 0.5, d = 6, units = "Eng") # See npartfull in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Corrugated Metal, 2) Stormdrain. data(npartfull) # We are using the culvert as a stormdrain in this problem nlocation <- grep("Stormdrain", npartfull$"Type of Conduit and Description") n <- as.numeric(npartfull[nlocation, 3]) # 3 for column 3 - Normal n Manningcirc(d = 6, Sf = 1 / 500, n = n, y = y$y, units = "Eng", output = "list") # d = 6 ft, Sf = 1 / 500 ft/ft, n = 0.024, y = 3 ft, units = "Eng" # This will solve for Q since it is missing and Q will be in ft^3/s # Example Problem 14.2 from Mott (pages 377-378) install.load::load_package("iemisc", "iemiscdata") y <- Manningcircy(y_d = 0.5, d = 200/1000, units = "SI") # See npartfull in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Clay, 2) Common drainage tile. data(npartfull) nlocation <- grep("Common drainage tile", npartfull$"Type of Conduit and Description") n <- as.numeric(npartfull[nlocation, 3]) # 3 for column 3 - Normal n Manningcirc(Sf = 1/1000, n = n, y = y$y, d = 200/1000, units = "SI", output = "list") # Sf = 1/1000 m/m, n = 0.013, y = 0.1 m, d = 200/1000 m, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s # Example 4.1 from Sturm (pages 124-125) Manningcircy(y_d = 0.8, d = 2, units = "Eng") y <- Manningcircy(y_d = 0.8, d = 2, units = "Eng") # defines all list values within the object named y y$y # gives the value of y # Modified Exercise 4.1 from Sturm (page 153) install.load::load_package("iemisc", "iemiscdata") # Note: The Q in Exercise 4.1 is actually found using the Chezy equation, # this is a modification of that problem # See nchannel in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Mountain streams, no vegetation # in channel, banks usually steep, trees and brush along banks submerged at # high stages and 3) bottom: gravels, cobbles, and few boulders. data(nchannel) nlocation <- grep("bottom: gravels, cobbles, and few boulders", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningcirc(Sf = 0.002, n = n, y = y$y, d = 2, units = "Eng", output = "data.table") # Sf = 0.002 ft/ft, n = 0.04, y = 1.6 ft, d = 2 ft, units = English units # This will solve for Q since it is missing and Q will be in ft^3/s # Modified Exercise 4.5 from Sturm (page 154) install.load::load_package("iemisc", "units") # create a numeric vector with the units of feet yeng <- set_units(y$y, ft) # create a numeric vector to convert from feet to meters ysi <- yeng # create a numeric vector with the units of meters units(ysi) <- make_units(m) # create a numeric vector with the units of feet deng <- set_units(2, ft) # create a numeric vector to convert from feet to meters dsi <- deng # create a numeric vector with the units of meters units(dsi) <- make_units(m) Manningcirc(Sf = 0.022, n = 0.023, y = drop_units(ysi), d = drop_units(dsi), units = "SI", output = "data.table") # Sf = 0.022 m/m, n = 0.023, y = 0.48768 m, d = 0.6096 m, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s# Practice Problem 14.12 from Mott (page 392) install.load::load_package("iemisc", "iemiscdata") y <- Manningcircy(y_d = 0.5, d = 6, units = "Eng") # See npartfull in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Corrugated Metal, 2) Stormdrain. data(npartfull) # We are using the culvert as a stormdrain in this problem nlocation <- grep("Stormdrain", npartfull$"Type of Conduit and Description") n <- as.numeric(npartfull[nlocation, 3]) # 3 for column 3 - Normal n Manningcirc(d = 6, Sf = 1 / 500, n = n, y = y$y, units = "Eng", output = "list") # d = 6 ft, Sf = 1 / 500 ft/ft, n = 0.024, y = 3 ft, units = "Eng" # This will solve for Q since it is missing and Q will be in ft^3/s # Example Problem 14.2 from Mott (pages 377-378) install.load::load_package("iemisc", "iemiscdata") y <- Manningcircy(y_d = 0.5, d = 200/1000, units = "SI") # See npartfull in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Clay, 2) Common drainage tile. data(npartfull) nlocation <- grep("Common drainage tile", npartfull$"Type of Conduit and Description") n <- as.numeric(npartfull[nlocation, 3]) # 3 for column 3 - Normal n Manningcirc(Sf = 1/1000, n = n, y = y$y, d = 200/1000, units = "SI", output = "list") # Sf = 1/1000 m/m, n = 0.013, y = 0.1 m, d = 200/1000 m, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s # Example 4.1 from Sturm (pages 124-125) Manningcircy(y_d = 0.8, d = 2, units = "Eng") y <- Manningcircy(y_d = 0.8, d = 2, units = "Eng") # defines all list values within the object named y y$y # gives the value of y # Modified Exercise 4.1 from Sturm (page 153) install.load::load_package("iemisc", "iemiscdata") # Note: The Q in Exercise 4.1 is actually found using the Chezy equation, # this is a modification of that problem # See nchannel in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Mountain streams, no vegetation # in channel, banks usually steep, trees and brush along banks submerged at # high stages and 3) bottom: gravels, cobbles, and few boulders. data(nchannel) nlocation <- grep("bottom: gravels, cobbles, and few boulders", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningcirc(Sf = 0.002, n = n, y = y$y, d = 2, units = "Eng", output = "data.table") # Sf = 0.002 ft/ft, n = 0.04, y = 1.6 ft, d = 2 ft, units = English units # This will solve for Q since it is missing and Q will be in ft^3/s # Modified Exercise 4.5 from Sturm (page 154) install.load::load_package("iemisc", "units") # create a numeric vector with the units of feet yeng <- set_units(y$y, ft) # create a numeric vector to convert from feet to meters ysi <- yeng # create a numeric vector with the units of meters units(ysi) <- make_units(m) # create a numeric vector with the units of feet deng <- set_units(2, ft) # create a numeric vector to convert from feet to meters dsi <- deng # create a numeric vector with the units of meters units(dsi) <- make_units(m) Manningcirc(Sf = 0.022, n = 0.023, y = drop_units(ysi), d = drop_units(dsi), units = "SI", output = "data.table") # Sf = 0.022 m/m, n = 0.023, y = 0.48768 m, d = 0.6096 m, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s
The Manningcircy function solves for one missing variable in the Gauckler- Manning equation for a circular cross-section and uniform flow. The possible inputs are y, d, y_d (ratio of y/d), and theta.
Manningcircy( y = NULL, d = NULL, y_d = NULL, theta = NULL, Sf = NULL, Q = NULL, units = c("SI", "Eng") )Manningcircy( y = NULL, d = NULL, y_d = NULL, theta = NULL, Sf = NULL, Q = NULL, units = c("SI", "Eng") )
y |
numeric vector that contains the flow depth (m or ft), if known. |
d |
numeric vector that contains the diameter value (m or ft), if known. |
y_d |
numeric vector that contains the filling ration (y/d), if known. |
theta |
numeric vector that contains the angle theta (radians), if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
units |
character vector that contains the system of units [options are
|
the missing parameters (d or y) & theta, area (A), wetted perimeters (P), top width (B), and hydraulic radius (R)
Irucka Embry
Manningcirc for the examples section
This function solves for one missing variable in the Gauckler-Manning-
Strickler equation for a parabolic cross-section and uniform flow. The
uniroot function is used to obtain the missing parameters.
Manningpara( Q = NULL, n = NULL, Sf = NULL, y = NULL, B1 = NULL, y1 = NULL, Temp = NULL, units = c("SI", "Eng"), output = c("list", "data.table") )Manningpara( Q = NULL, n = NULL, Sf = NULL, y = NULL, B1 = NULL, y1 = NULL, Temp = NULL, units = c("SI", "Eng"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
B1 |
numeric vector that contains the "bank-full width", if known. |
y1 |
numeric vector that contains the "bank-full depth", if known. |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. |
units |
character vector that contains the system of units [options are
|
output |
character vector that contains the output type, either it will
be a |
Gauckler-Manning-Strickler equation is expressed as
the velocity (m/s or ft/s)
Manning's roughness coefficient (dimensionless)
the hydraulic radius (m or ft)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
This equation is also expressed as
the discharge [m^3/s or ft^3/s (cfs)] is VA
Manning's roughness coefficient (dimensionless)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
Other important equations regarding the parabolic cross-section follow:
the hydraulic radius (m or ft)
the cross-sectional area (m^2 or ft^2)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the top width of the channel (m or ft)
the wetted perimeter of the channel (m or ft)
the top width of the channel (m or ft)
4y/b (dimensionless)
4y/b (dimensionless)
the top width of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the top width of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the "bank-full width" (m or ft)
the "bank-full depth" (m or ft)
the hydraulic depth (m or ft)
the cross-sectional area (m^2 or ft^2)
the top width of the channel (m or ft)
the Section factor (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the Specific Energy (m or ft)
the discharge [m^3/s or ft^3/s (cfs)] is VA
gravitational acceleration (m/s^2 or ft/sec^2)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the Velocity Head (m or ft)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
A rough turbulent zone check is performed on the water flowing in the channel using the Reynolds number (Re). The Re equation follows:
Reynolds number (dimensionless)
density (kg/m^3 or slug/ft^3)
the hydraulic radius (m or ft)
the velocity (m/s or ft/s)
dynamic viscosity (* 10^-3 kg/m*s or * 10^-5 lb*s/ft^2)
A critical flow check is performed on the water flowing in the channel using the Froude number (Fr). The Fr equation follows:
the Froude number (dimensionless)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
the hydraulic depth (m or ft)
the missing parameters (Q, n, Sf, B1, y1, or y) & V (velocity),
Flow depth (y), Slope (Sf), A (area), P (wetted perimeters), R (hydraulic
radius), B (top width), D (hydraulic depth), y1 (Bank-full depth), B1
(Bank-full Width), Z (Section Factor), E (Specific Energy), K
(conveyance), Vel_Head (Velocity Head), Re (Reynolds number), Fr (Froude
number), taud (maximum shear stress), tau0 (average shear stress) as a list.
Alternatively, the Flow depth (y), Bank-full depth (y1), Flow area (A),
Wetted Perimeter (P), Top Width (B), Bank-full Width (B1), Hydraulic
Radius (R), Hydraulic Depth (D), Flow Mean Velocity (V), Flow Discharge
(Q), Manning's roughness coefficient (n), Slope (Sf), Temperature,
Absolute Temperature, Saturated Liquid Density, Absolute or Dynamic
Viscosity, Kinematic Viscosity, Froude number (Fr), Reynolds number (Re),
Section Factor (Z), conveyance (K), Specific Energy (E), Velocity Head
(Vel_Head), Maximum Shear Stress (taud), Average Shear Stress (tau0)
along with the associated units can be returned in a data.table.
Assumptions: uniform flow, prismatic channel, and surface water temperature of 20 degrees Celsius (68 degrees Fahrenheit) at atmospheric pressure
Note: Units must be consistent
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 2, 8, 36, 102, 120, 153.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Gilberto E. Urroz, Utah State University Civil and Environmental Engineering - OCW, CEE6510 - Numerical Methods in Civil Engineering, Spring 2006 (2006). Course 3. "Solving selected equations and systems of equations in hydraulics using Matlab", August/September 2004, https://digitalcommons.usu.edu/ocw_cee/3/.
Tyler G. Hicks, P.E., Civil Engineering Formulas: Pocket Guide, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2002, pages 423, 425.
Wikimedia Foundation, Inc. Wikipedia, 26 November 2015, "Manning formula", https://en.wikipedia.org/wiki/Manning_formula.
John C. Crittenden, R. Rhodes Trussell, David W. Hand, Kerry J. Howe, George Tchobanoglous, MWH's Water Treatment: Principles and Design, Third Edition, Hoboken, New Jersey: John Wiley & Sons, Inc., 2012, pages 1861-1862.
Andrew Chadwick, John Morfett and Martin Borthwick, Hydraulics in Civil and Environmental Engineering, Fourth Edition, New York City, New York: Spon Press, Inc., 2004, page 133.
Robert L. Mott and Joseph A. Untener, Applied Fluid Mechanics, Seventh Edition, New York City, New York: Pearson, 2015, page 376.
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 21, 40-41.
Gary P. Merkley, "BIE6300 - Irrigation & Conveyance Control Systems, Spring 2004", 2004, Biological and Irrigation Engineering - OCW. Course 2, https://digitalcommons.usu.edu/ocw_bie/2/.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Wikimedia Foundation, Inc. Wikipedia, 15 May 2019, "Conversion of units", https://en.wikipedia.org/wiki/Conversion_of_units.
Manningtrap for a trapezoidal cross-section, Manningrect for a
rectangular cross-section, Manningtri for a triangular cross-section,
Manningcirc for a circular cross-section, and Manning for the wrapper function.
library(iemisc) # Exercise 4.3 from Sturm (page 153) y <- Manningpara(Q = 12.0, B1 = 10, y1 = 2.0, Sf = 0.005, n = 0.05, units = "SI", output = "list") # defines all list values within the object named y # Q = 12.0 m^3/s, B1 = 10 m, y1 = 2.0 m, Sf = 0.005 m/m, n = 0.05, units = SI units # This will solve for y since it is missing and y will be in m y$y # gives the value of y # Modified Exercise 4.3 from Sturm (page 153) Manningpara(y = y$y, B1 = 10, y1 = 2.0, Sf = 0.005, n = 0.05, units = "SI", output = "data.table") # y = 1.254427 m, B1 = 10 m, y1 = 2.0 m, Sf = 0.005 m/m, n = 0.05, units = SI units # This will solve for Q since it is missing and Q will be in m^3/slibrary(iemisc) # Exercise 4.3 from Sturm (page 153) y <- Manningpara(Q = 12.0, B1 = 10, y1 = 2.0, Sf = 0.005, n = 0.05, units = "SI", output = "list") # defines all list values within the object named y # Q = 12.0 m^3/s, B1 = 10 m, y1 = 2.0 m, Sf = 0.005 m/m, n = 0.05, units = SI units # This will solve for y since it is missing and y will be in m y$y # gives the value of y # Modified Exercise 4.3 from Sturm (page 153) Manningpara(y = y$y, B1 = 10, y1 = 2.0, Sf = 0.005, n = 0.05, units = "SI", output = "data.table") # y = 1.254427 m, B1 = 10 m, y1 = 2.0 m, Sf = 0.005 m/m, n = 0.05, units = SI units # This will solve for Q since it is missing and Q will be in m^3/s
This function solves for one missing variable in the Gauckler-Manning-
Strickler equation for a rectangular cross-section and uniform flow. The
uniroot function is used to obtain the missing parameters.
Manningrect( Q = NULL, n = NULL, b = NULL, Sf = NULL, y = NULL, Temp = NULL, units = c("SI", "Eng"), output = c("list", "data.table") )Manningrect( Q = NULL, n = NULL, b = NULL, Sf = NULL, y = NULL, Temp = NULL, units = c("SI", "Eng"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
b |
numeric vector that contains the bottom width, if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. |
units |
character vector that contains the system of units [options are
|
output |
character vector that contains the output type, either it will
be a |
Gauckler-Manning-Strickler equation is expressed as
the velocity (m/s or ft/s)
Manning's roughness coefficient (dimensionless)
the hydraulic radius (m or ft)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
This equation is also expressed as
the discharge [m^3/s or ft^3/s (cfs)] is VA
Manning's roughness coefficient (dimensionless)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
Other important equations regarding the rectangular cross-section follow:
the hydraulic radius (m or ft)
the cross-sectional area (m^2 or ft^2)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the bottom width (m or ft)
the wetted perimeter of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the bottom width (m or ft)
the top width of the channel (m or ft)
the bottom width (m or ft)
the hydraulic depth (m or ft)
the cross-sectional area (m^2 or ft^2)
the top width of the channel (m or ft)
the Section factor (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the Specific Energy (m or ft)
the discharge [m^3/s or ft^3/s (cfs)] is VA
gravitational acceleration (m/s^2 or ft/sec^2)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the Velocity Head (m or ft)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
A rough turbulent zone check is performed on the water flowing in the channel using the Reynolds number (Re). The Re equation follows:
Reynolds number (dimensionless)
density (kg/m^3 or slug/ft^3)
the hydraulic radius (m or ft)
the velocity (m/s or ft/s)
dynamic viscosity (* 10^-3 kg/m*s or * 10^-5 lb*s/ft^2)
A critical flow check is performed on the water flowing in the channel using the Froude number (Fr). The Fr equation follows:
the Froude number (dimensionless)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
the hydraulic depth (m or ft)
the missing parameters (Q, n, b, Sf, or y) & area (A), wetted
perimeters (P), velocity (V), top width (B), hydraulic depth (D), hydraulic
radius (R), E (Specific Energy), Vel_Head (Velocity Head), Z (Section
Factor), E (Specific Energy), K (conveyance), Vel_Head (Velocity Head), Re
(Reynolds number), Fr (Froude number), taud (maximum shear stress), tau0
(average shear stress) as a list.
Alternatively, the Flow depth (y), Flow area (A), Wetted Perimeter (P),
Bottom width (b), Top Width (B), Hydraulic Radius (R), Hydraulic Depth (D),
Flow Mean Velocity (V), Flow Discharge (Q), Manning's roughness coefficient
(n), Slope (Sf), Temperature, Absolute Temperature, Saturated Liquid Density,
Absolute or Dynamic Viscosity, Kinematic Viscosity, Froude number (Fr),
Reynolds number (Re), Section Factor (Z), conveyance (K), Specific Energy
(E), Velocity Head (Vel_Head), Maximum Shear Stress (taud), Average Shear
Stress (tau0) along with the associated units can be returned in a
data.table.
Assumptions: uniform flow, prismatic channel, and surface water temperature of 20 degrees Celsius (68 degrees Fahrenheit) at atmospheric pressure
Note: Units must be consistent
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 2, 8, 36, 102, 120, 153-154.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Gilberto E. Urroz, Utah State University Civil and Environmental Engineering - OCW, CEE6510 - Numerical Methods in Civil Engineering, Spring 2006 (2006). Course 3. "Solving selected equations and systems of equations in hydraulics using Matlab", August/September 2004, https://digitalcommons.usu.edu/ocw_cee/3/.
Tyler G. Hicks, P.E., Civil Engineering Formulas: Pocket Guide, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2002, pages 423, 425.
Wikimedia Foundation, Inc. Wikipedia, 26 November 2015, "Manning formula", https://en.wikipedia.org/wiki/Manning_formula.
John C. Crittenden, R. Rhodes Trussell, David W. Hand, Kerry J. Howe, George Tchobanoglous, MWH's Water Treatment: Principles and Design, Third Edition, Hoboken, New Jersey: John Wiley & Sons, Inc., 2012, pages 1861-1862.
Andrew Chadwick, John Morfett and Martin Borthwick, Hydraulics in Civil and Environmental Engineering, Fourth Edition, New York City, New York: Spon Press, Inc., 2004, page 133.
Robert L. Mott and Joseph A. Untener, Applied Fluid Mechanics, Seventh Edition, New York City, New York: Pearson, 2015, pages 376, 379-380.
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 21, 40-41.
Gary P. Merkley, "BIE6300 - Irrigation & Conveyance Control Systems, Spring 2004", 2004, Biological and Irrigation Engineering - OCW. Course 2, https://digitalcommons.usu.edu/ocw_bie/2/.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Wikimedia Foundation, Inc. Wikipedia, 15 May 2019, "Conversion of units", https://en.wikipedia.org/wiki/Conversion_of_units.
Manningtrap for a trapezoidal cross-section, Manningtri
for a triangular cross-section, Manningpara for a parabolic
cross-section, Manningcirc for a circular cross-section, and Manning for the wrapper function.
install.load::load_package("iemisc", "iemiscdata") # Example Problem 14.4 from Mott (page 379) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Lined or Constructed Channels, # 3) Concrete, and 4) unfinished. data(nchannel) nlocation <- grep("unfinished", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningrect(Q = 5.75, b = (4.50) ^ (3 / 8), Sf = 1.2/100, n = n, units = "SI", output = "data.table") # Q = 5.75 m^3/s, b = (4.50) ^ (3 / 8) m, Sf = 1.2 percent m/m, n = 0.017, # units = SI units # This will solve for y since it is missing and y will be in m # Example Problem 14.5 from Mott (pages 379-380) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Lined or Constructed Channels, # 3) Concrete, and 4) unfinished. data(nchannel) nlocation <- grep("unfinished", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningrect(Q = 12, b = 2, Sf = 1.2/100, n = n, units = "SI", output = "data.table") # Q = 12 m^3/s, b = 2 m, Sf = 1.2 percent m/m, n = 0.017, units = SI # units # This will solve for y since it is missing and y will be in minstall.load::load_package("iemisc", "iemiscdata") # Example Problem 14.4 from Mott (page 379) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Lined or Constructed Channels, # 3) Concrete, and 4) unfinished. data(nchannel) nlocation <- grep("unfinished", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningrect(Q = 5.75, b = (4.50) ^ (3 / 8), Sf = 1.2/100, n = n, units = "SI", output = "data.table") # Q = 5.75 m^3/s, b = (4.50) ^ (3 / 8) m, Sf = 1.2 percent m/m, n = 0.017, # units = SI units # This will solve for y since it is missing and y will be in m # Example Problem 14.5 from Mott (pages 379-380) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Lined or Constructed Channels, # 3) Concrete, and 4) unfinished. data(nchannel) nlocation <- grep("unfinished", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningrect(Q = 12, b = 2, Sf = 1.2/100, n = n, units = "SI", output = "data.table") # Q = 12 m^3/s, b = 2 m, Sf = 1.2 percent m/m, n = 0.017, units = SI # units # This will solve for y since it is missing and y will be in m
This function solves for one missing variable in the Gauckler-Manning-
Strickler equation for a trapezoidal cross-section and uniform flow. The
uniroot function is used to obtain the missing parameters.
Manningtrap( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, b = NULL, Temp = NULL, units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), output = c("list", "data.table") )Manningtrap( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, b = NULL, Temp = NULL, units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
m |
numeric vector that contains the symmetric "cross-sectional side slope of m:V (horizontal:vertical)", if known. |
m1 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m1:V (horizontal:vertical)", if known. |
m2 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m2:V (horizontal:vertical)", if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
b |
numeric vector that contains the bottom width, if known. |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. Otherwise, the default value is 20 degrees Celsius (68 degrees Fahrenheit). |
units |
character vector that contains the system of units [options are
|
type |
character vector that contains the type of trapezoid (symmetrical
or non-symmetrical). The symmetrical trapezoid uses |
output |
character vector that contains the output type, either it will
be a |
Parameters Definitions from Chow pages 7, 13, 20, 22-23 "The depth of flow y is the vertical distance of the lowest point of a channel section from the free surface."
"The top width Temp is the width of channel section at the free surface."
"The water area A is water area of the flow normal to the direction of flow."
"The wetted perimeters P is the length of the line of intersection of the channel wetted surface with a cross-sectional plane normal to the direction of flow."
"The hydraulic radius R is the ratio of the water area to its wetted perimeters."
"The hydraulic radius D is the ratio of the water area to the top width."
"The section factor for critical-flow computation Z is the product of the water area and the square root of the hydraulic depth."
"The section factor for uniform-flow computation AR^2/3 is the product of the water area and the two-thirds power of the hydraulic radius."
"A channel built with unvarying cross section and constant bottom slope is called a prismatic channel. Otherwise, the channel is nonprismatic."
"For any flow, the discharge Q at a channel section is expressed by Q = V A where V is the mean velocity and A is the flow cross-sectional area normal to the direction of the flow, since the mean velocity is defined as the discharge divided by the cross-sectional area."
"The effect of viscosity relative to inertia can be represented by the Reynolds number. ..."
"The effect of gravity upon the state of flow is represented by a ratio of inertial forces to gravity forces. This ratio is given by the Froude number. ..."
The References for the following equations, include, but are not limited to: Chow pages 5, 7, 13, 21, 23, 28; Schall pages 4-17 and 5-5; Wikimedia Conversion and Manning
Gauckler-Manning-Strickler equation is expressed as
the mean velocity (m/s or ft/sec)
Manning's roughness coefficient (dimensionless)
the hydraulic radius (m or ft)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
This equation is also expressed as
the discharge [m^3/s or ft^3/s (cfs)] is VA
Manning's roughness coefficient (dimensionless)
the wetted perimeter of the channel (m or ft)
water area (m^2 or ft^2)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
Other important equations regarding the trapezoidal cross-section follow:
the hydraulic radius (m or ft)
water area (m^2 or ft^2)
the wetted perimeter of the channel (m or ft)
water area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the bottom width (m or ft)
the wetted perimeter of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the bottom width (m or ft)
the top width of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the bottom width (m or ft)
the hydraulic depth (m or ft)
water area (m^2 or ft^2)
the top width of the channel (m or ft)
According to Chow, "the section factor for uniform-flow computation AR^2/3 is the product of the water area and the two-thirds power of the hydraulic radius" & "the section factor for critical-flow computation Z is the product of the water area and the square root of the hydraulic depth" (page 23).
the Section factor (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the bottom width (m or ft)
the Specific Energy (m or ft)
the discharge [m^3/s or ft^3/s (cfs)] is VA
gravitational acceleration (m/s^2 or ft/sec^2)
water area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the Velocity Head (m or ft)
the mean velocity (m/s or ft/sec)
gravitational acceleration (m/s^2 or ft/sec^2)
the Wetted Length (m or ft)
the horizontal side slope
the flow depth (normal depth in this function) [m or ft]
"mean boundary shear stress" (N/m^2 or lbf/ft^2)
unit weight of water at the given temperature (N/m^3 or lbf/ft^3)
the hydraulic radius (m or ft)
the slope of the channel bed ["average bottom slope (equal to energy slope for uniform flow)"] (m/m or ft/ft)
"shear stress in channel at maximum depth" (N/m^2 or lbf/ft^2)
unit weight of water at the given temperature (N/m^3 or lbf/ft^3)
the flow depth ("maximum depth of flow in the channel for the design discharge") [m or ft]
the slope of the channel bed ["average bottom slope (equal to energy slope for uniform flow)"] (m/m or ft/ft)
# where
unit weight of water at the given temperature (N/m^3 or lbf/ft^3)
gravitational acceleration (m/s^2 or ft/sec^2)
density of the fluid at a certain temperature (kg/m^3 or slugs/ft^3)
unit weight of water at the given temperature (lbf/ft^3)
density of the fluid at a certain temperature (lbm/ft^3)
gravitational acceleration (m/s^2 or ft/sec^2)
gravitational constant (32.2 lbm-ft/lbf-sec^2) used for dimensional analysis so that the Reynolds number will be dimensionless with US Customary units
channel conveyance (m^3/s or ft^3/sec)
unit conversion factor (1 in SI and 3.2808399^(1/3) in US Customary units
water area (m^2 or ft^2)
the hydraulic radius (m or ft)
Manning's roughness coefficient (dimensionless)
A rough turbulent zone check is performed on the water flowing in the channel using the Reynolds number (Re). The Re equation follows:
Reynolds number (dimensionless)
water density (kg/m^3 or slug/ft^3)
the hydraulic radius (m or ft)
the mean velocity (m/s or ft/sec)
dynamic viscosity (* 10^-3 kg/m*s or * 10^-5 lb*sec/ft^2)
A critical flow check is performed on the water flowing in the channel using the Froude number (Fr). The Fr equation follows:
the Froude number (dimensionless)
the mean velocity (m/s or ft/sec)
gravitational acceleration (m/s^2 or ft/sec^2)
the hydraulic depth (m or ft)
the missing parameters (Q, n, b, m, m1, m2, Sf, or y) & V (velocity),
Flow depth (y), Bottom width (b), symmetric side slope (m), Slope (Sf),
A (area), P (wetted perimeters), R (hydraulic radius), B (top width), D
(hydraulic depth), w (Wetted Length), w1 (Wetted Length for a
non-symmetric trapezoid), w2 (Wetted Length for a non-symmetric trapezoid),
Z (Section Factor), E (Specific Energy), K (conveyance), Vel_Head (Velocity
Head), Re (Reynolds number), Fr (Froude number), taud (maximum shear
stress), tau0 (average shear stress) as a list.
Alternatively, the Flow depth (y), Flow area (A), Wetted Perimeter (P),
Top Width (B), Bottom width (b), Hydraulic Radius (R), Hydraulic Depth (D),
Flow Mean Velocity (V), Flow Discharge (Q), Manning's roughness coefficient
(n), Slope (Sf), Temperature, Absolute Temperature, Saturated Liquid
Density, Absolute or Dynamic Viscosity, Kinematic Viscosity, Froude number
(Fr), Reynolds number (Re), symmetric side slope (m), non-symmetric side
slope (m1), non-symmetric side slope (m2), Wetted Length (w), Wetted Length
for a non-symmetric trapezoid (w1), Wetted Length for a non-symmetric
trapezoid (w2), Section Factor (Z), conveyance (K), Specific Energy (E),
Velocity Head (Vel_Head), Maximum Shear Stress (taud), Average Shear Stress
(tau0) along with the associated units can be returned in a data.table.
Assumption: Surface water temperature of 20 degrees Celsius (68 degrees Fahrenheit) at atmospheric pressure
Note: Units must be consistent
Irucka Embry
Harlan Bengtson, "Calculation of Open Channel Flow Hydraulic Radius: Calculate using Trapezoid Area", Bright Hub Engineering Hydraulics in Civil Engineering, https://www.brighthubengineering.com/hydraulics-civil-engineering/67126-calculation-of-hydraulic-radius-for-uniform-open-channel-flow/.
Andrew Chadwick, John Morfett, and Martin Borthwick, Hydraulics in Civil and Environmental Engineering, Fourth Edition, New York City, New York: Spon Press, 2004, pages 132-133.
R.J. Charbeneau, "Topic 8: Open Channel Flow", CE 365K Hydraulic Engineering Design, The University of Texas at Austin Cockrell School of Engineering Department of Civil, Architectural and Environmental Engineering, https://www.caee.utexas.edu/prof/maidment/CE365KSpr14/Visual/OpenChannels.pdf.
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 7-8, 13, 20-23, 28, 39-43.
John C. Crittenden, R. Rhodes Trussell, David W. Hand, Kerry J. Howe, George Tchobanoglous, MWH's Water Treatment: Principles and Design, Third Edition, Hoboken, New Jersey: John Wiley & Sons, Inc., 2012, pages 1861-1862.
Prof. Dr. Aminuddin Ab Ghani, "Specific Energy & Hydraulic Jump", Universiti Sains Malaysia (USM) Engineering Campus River Engineering and Urban Drainage Research Centre (REDACE), https://web.archive.org/web/20200110165556/https://redac.eng.usm.my/EAH/Handouts/Specific%20Energy%202011.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Tyler G. Hicks, P.E., Civil Engineering Formulas: Pocket Guide, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2002, pages 423, 425.
Gary P. Merkley, "BIE6300 - Irrigation & Conveyance Control Systems, Spring 2004", 2004, Biological and Irrigation Engineering - OCW. Course 2, https://digitalcommons.usu.edu/ocw_bie/2/.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Robert L. Mott and Joseph A. Untener, Applied Fluid Mechanics, Seventh Edition, New York City, New York: Pearson, 2015, pages 376, 392.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
James D. Schall, Everett V. Richardson, and Johnny L. Morris, U.S. Department of Transportation Federal Highway Administration & National Highway Institute (NHI) and Office of Bridge Technology (HIBTemp), Introduction to Highway Hydraulics: Hydraulic Design Series Number 4, Fourth Edition, June 2008, pages 4-5, 4-16 - 4-17 and 5-5, https://www.fhwa.dot.gov/engineering/hydraulics/pubs/08090/HDS4_608.pdf.
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 2, 8, 36, 102, 120, 153.
US Department of Transportation Federal Highway Administration (FHWA), "Urban Drainage Design Manual", Hydraulic Engineering Circular No. 22, Third Edition, Publication No. FHWA-NHI-10-009 September 2009 (Revised August 2013), pages 5-7 - 5-8, https://www.fhwa.dot.gov/engineering/hydraulics/library_arc.cfm?pub_number=22&id=140.
Ali R.Vatankhah, "Explicit solutions for critical and normal depths in trapezoidal and parabolic open channels", Ain Shams Engineering Journal, Volume 4, Issue 1, March 2013, Pages 17-23, https://www.sciencedirect.com/science/article/pii/S2090447912000329.
Wikimedia Foundation, Inc. Wikipedia, 15 May 2019, "Conversion of units", https://en.wikipedia.org/wiki/Conversion_of_units.
Wikimedia Foundation, Inc. Wikipedia, 23 May 2019, "Manning formula", https://en.wikipedia.org/wiki/Manning_formula.
Manningrect for a rectangular cross-section, Manningtri
for a triangular cross-section, Manningpara for a parabolic
cross-section, Manningcirc for a circular cross-section, and Manning for the wrapper function.
# Example 1 library(iemisc) # Exercise 4.1 from Sturm (page 153) uu <- Manningtrap(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", type = "symmetrical", output = "list") # Q = 3000 cfs, b = 40 ft, m = 3, Sf = 0.002 ft/ft, n = 0.025, # units = English units # This will solve for y since it is missing and y will be in ft uu$y # only returns y uu # returns all results # Example 2 install.load::load_package("iemisc", "iemiscdata") # Practice Problem 14.19 from Mott (page 392) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the minimum Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft) Lined or Constructed Channels, # 3) Concrete and 4) float finish. data(nchannel) nlocation <- grep("float finish", nchannel$"Type of Channel and Description")[1] # select the 1st row (c. Concrete 2. float finish) n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n tt <- Manningtrap(y = 1.5, b = 3, m = 3/2, Sf = 0.1/100, n = n, units = "SI", type = "symmetrical", output = "list") # y = 1.5 m, b = 3 m, m = 3/2, Sf = 0.1/100 m/m, n = 0.023, units = SI # units # This will solve for Q since it is missing and Q will be in m^3/s tt$Q # only returns Q tt # returns all results# Example 1 library(iemisc) # Exercise 4.1 from Sturm (page 153) uu <- Manningtrap(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", type = "symmetrical", output = "list") # Q = 3000 cfs, b = 40 ft, m = 3, Sf = 0.002 ft/ft, n = 0.025, # units = English units # This will solve for y since it is missing and y will be in ft uu$y # only returns y uu # returns all results # Example 2 install.load::load_package("iemisc", "iemiscdata") # Practice Problem 14.19 from Mott (page 392) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the minimum Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft) Lined or Constructed Channels, # 3) Concrete and 4) float finish. data(nchannel) nlocation <- grep("float finish", nchannel$"Type of Channel and Description")[1] # select the 1st row (c. Concrete 2. float finish) n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n tt <- Manningtrap(y = 1.5, b = 3, m = 3/2, Sf = 0.1/100, n = n, units = "SI", type = "symmetrical", output = "list") # y = 1.5 m, b = 3 m, m = 3/2, Sf = 0.1/100 m/m, n = 0.023, units = SI # units # This will solve for Q since it is missing and Q will be in m^3/s tt$Q # only returns Q tt # returns all results
This function solves for one missing variable in the Gauckler-Manning-
Strickler equation for a trapezoidal cross-section and uniform flow. The
uniroot function is used to obtain the missing parameters.
This function provides both normal and critical parameters values.
Manningtrap_critical( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, b = NULL, Temp = NULL, units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), critical = c("approximate", "accurate"), output = c("list", "data.table") )Manningtrap_critical( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, b = NULL, Temp = NULL, units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), critical = c("approximate", "accurate"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
m |
numeric vector that contains the symmetric "cross-sectional side slope of m:V (horizontal:vertical)", if known. |
m1 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m1:V (horizontal:vertical)", if known. |
m2 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m2:V (horizontal:vertical)", if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
b |
numeric vector that contains the bottom width, if known. |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. |
units |
character vector that contains the system of units [options are
|
type |
character vector that contains the type of trapezoid (symmetrical
or non-symmetrical). The symmetrical trapezoid uses |
critical |
character vector that contains the type of critical parameters
calculations ( |
output |
character vector that contains the output type, either it will be
a |
Critical State Discussion from Chow pages 13, 63 "When F (Froude number) is equal to unity, ... the flow is said to be in a critical state. If F is less than unity, ... the flow is subcritical. If F is greater than unity, ... the flow is supercritical."
"... the critical state of flow through a channel section is characterized by several important conditions. Recapitulating, they are (1) the specific energy is a minimum for a given discharge; (2) the discharge is a maximum for a given specific energy; (3) the specific force is a minimum for a given discharge; (4) the velocity head is equal to half the hydraulic depth in a channel of small slope; (5) the Froude number is equal to unity; and (6) the velocity of flow in a channel of small slope with uniform velocity distribution is equal to the celerity of small gravity waves in shallow water caused by local disturbances."
"Discussions on critical state of flow have referred mainly to a particular section of a channel, known as the critical section. If the critical state of exists throughout the entire length of the channel or over a reach of the channel, the flow in the channel is a critical flow."
the missing parameters (Q, n, b, m, m1, m2, Sf, or y) & V (velocity),
Flow depth (y), Bottom width (b), symmetric side slope (m), Slope (Sf),
A (area), P (wetted perimeters), R (hydraulic radius), B (top width), D
(hydraulic depth), w (Wetted Length), w1 (Wetted Length for a
non-symmetric trapezoid), w2 (Wetted Length for a non-symmetric trapezoid),
Z (Section Factor), E (Specific Energy), K (conveyance), Vel_Head (Velocity
Head), Re (Reynolds number), Fr (Froude number), taud (maximum shear
stress), tau0 (average shear stress), yc (critical depth), Ac (critical
area), Pc (critical wetted perimeters), Bc (critical top width), Rc (critical
hydraulic radius), Dc (critical hydraulic depth), Vc (critical velocity), Qc
(critical discharge), Sfc (critical slope), Frc (critical Froude number), Zc
(critical Section Factor), Ec (critical Specific Energy) as a list.
Alternatively, the Flow depth (y), Flow area (A), Wetted Perimeter (P),
Top Width (B), Bottom width (b), Hydraulic Radius (R), Hydraulic Depth (D),
Flow Mean Velocity (V), Flow Discharge (Q), Manning's roughness coefficient
(n), Slope (Sf), Temperature, Absolute Temperature, Saturated Liquid
Density, Absolute or Dynamic Viscosity, Kinematic Viscosity, Froude number
(Fr), Reynolds number (Re), symmetric side slope (m), non-symmetric side
slope (m1), non-symmetric side slope (m2), Wetted Length (w), Wetted Length
for a non-symmetric trapezoid (w1), Wetted Length for a non-symmetric
trapezoid (w2), Section Factor (Z), conveyance (K), Specific Energy (E),
Velocity Head (Vel_Head), Maximum Shear Stress (taud), Average Shear Stress
(tau0) along with the associated units can be returned in a data.table.
Both the normal and the critical values (where present) are returned in the
table.
Irucka Embry
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 13, 63.
# Example 1 library(iemisc) # Exercise 4.1 from Sturm (page 153) uuc <- Manningtrap_critical(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", type = "symmetrical", critical = "accurate", output = "list") # Q = 3000 cfs, b = 40 ft, m = 3, Sf = 0.002 ft/ft, n = 0.025, # units = English units # This will solve for y since it is missing and y will be in ft uuc$y # only returns y uuc # returns all results # Example 2 install.load::load_package("iemisc", "iemiscdata") # Practice Problem 14.19 from Mott (page 392) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the minimum Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft) Lined or Constructed Channels, # 3) Concrete and 4) float finish. data(nchannel) nlocationc <- grep("float finish", nchannel$"Type of Channel and Description") nc <- as.numeric(nchannel[nlocationc, 3][1]) # 3 for column 3 - Normal n ttc <- Manningtrap_critical(y = 1.5, b = 3, m = 3/2, Sf = 0.1/100, n = nc, units = "SI", type = "symmetrical", critical = "accurate", output = "list") # y = 1.5 m, b = 3 m, m = 3/2, Sf = 0.1/100 m/m, n = 0.023, units = SI # units # This will solve for Q since it is missing and Q will be in m^3/s ttc$Q # only returns Q ttc # returns all results# Example 1 library(iemisc) # Exercise 4.1 from Sturm (page 153) uuc <- Manningtrap_critical(Q = 3000, b = 40, m = 3, Sf = 0.002, n = 0.025, units = "Eng", type = "symmetrical", critical = "accurate", output = "list") # Q = 3000 cfs, b = 40 ft, m = 3, Sf = 0.002 ft/ft, n = 0.025, # units = English units # This will solve for y since it is missing and y will be in ft uuc$y # only returns y uuc # returns all results # Example 2 install.load::load_package("iemisc", "iemiscdata") # Practice Problem 14.19 from Mott (page 392) # See nchannel in iemiscdata for the Manning's n table that the following # example uses # Use the minimum Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft) Lined or Constructed Channels, # 3) Concrete and 4) float finish. data(nchannel) nlocationc <- grep("float finish", nchannel$"Type of Channel and Description") nc <- as.numeric(nchannel[nlocationc, 3][1]) # 3 for column 3 - Normal n ttc <- Manningtrap_critical(y = 1.5, b = 3, m = 3/2, Sf = 0.1/100, n = nc, units = "SI", type = "symmetrical", critical = "accurate", output = "list") # y = 1.5 m, b = 3 m, m = 3/2, Sf = 0.1/100 m/m, n = 0.023, units = SI # units # This will solve for Q since it is missing and Q will be in m^3/s ttc$Q # only returns Q ttc # returns all results
This function solves for one missing variable in the Gauckler-Manning-
Strickler equation for a triangular cross-section and uniform flow. The
uniroot function is used to obtain the missing parameters.
Manningtri( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, Temp = NULL, units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), output = c("list", "data.table") )Manningtri( Q = NULL, n = NULL, m = NULL, m1 = NULL, m2 = NULL, Sf = NULL, y = NULL, Temp = NULL, units = c("SI", "Eng"), type = c("symmetrical", "non-symmetrical"), output = c("list", "data.table") )
Q |
numeric vector that contains the discharge value (m^3/s or ft^3/s), if known. |
n |
numeric vector that contains the Manning's roughness coefficient n, if known. |
m |
numeric vector that contains the "cross-sectional side slope of m:1 (horizontal:vertical)", if known. |
m1 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m1:V (horizontal:vertical)", if known. |
m2 |
numeric vector that contains the non-symmetric "cross-sectional side slope of m2:V (horizontal:vertical)", if known. |
Sf |
numeric vector that contains the bed slope (m/m or ft/ft), if known. |
y |
numeric vector that contains the flow depth (m or ft), if known. |
Temp |
numeric vector that contains the temperature (degrees C or degrees Fahrenheit), if known. |
units |
character vector that contains the system of units [options are
|
type |
character vector that contains the type of triangle (symmetrical
or non-symmetrical). The symmetrical triangle uses |
output |
character vector that contains the output type, either it will
be a |
Gauckler-Manning-Strickler equation is expressed as
the velocity (m/s or ft/s)
Manning's roughness coefficient (dimensionless)
the hydraulic radius (m or ft)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
This equation is also expressed as
the discharge [m^3/s or ft^3/s (cfs)] is VA
Manning's roughness coefficient (dimensionless)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the slope of the channel bed (m/m or ft/ft)
the conversion constant – 1.0 for SI and 3.2808399 ^ (1 / 3) for English units – m^(1/3)/s or ft^(1/3)/s
Other important equations regarding the triangular cross-section follow:
the hydraulic radius (m or ft)
the cross-sectional area (m^2 or ft^2)
the wetted perimeter of the channel (m or ft)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the wetted perimeter of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the top width of the channel (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the hydraulic depth (m or ft)
the cross-sectional area (m^2 or ft^2)
the top width of the channel (m or ft)
the Section factor (m or ft)
the flow depth (normal depth in this function) [m or ft]
the horizontal side slope
the Specific Energy (m or ft)
the discharge [m^3/s or ft^3/s (cfs)] is VA
gravitational acceleration (m/s^2 or ft/sec^2)
the cross-sectional area (m^2 or ft^2)
the flow depth (normal depth in this function) [m or ft]
the Velocity Head (m or ft)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
the Wetted Length (m or ft)
the horizontal side slope
the flow depth (normal depth in this function) [m or ft]
A rough turbulent zone check is performed on the water flowing in the channel using the Reynolds number (Re). The Re equation follows:
Reynolds number (dimensionless)
density (kg/m^3 or slug/ft^3)
the hydraulic radius (m or ft)
the velocity (m/s or ft/s)
dynamic viscosity (* 10^-3 kg/m*s or * 10^-5 lb*s/ft^2)
A critical flow check is performed on the water flowing in the channel using the Froude number (Fr). The Fr equation follows:
the Froude number (dimensionless)
the velocity (m/s or ft/s)
gravitational acceleration (m/s^2 or ft/sec^2)
the hydraulic depth (m or ft)
the missing parameters (Q, n, m, m1, m2, Sf, or y) & Flow depth (y),
Slope (Sf), A (area), P (wetted perimeters), R (hydraulic radius), B
(top width), D (hydraulic depth), Z (Section Factor), E (Specific Energy),
K (conveyance), Vel_Head (Velocity Head), Re (Reynolds number), Fr (Froude
number), taud (maximum shear stress), tau0 (average shear stress) as a list.
Alternatively, the Flow depth (y), Flow area (A), Wetted Perimeter (P),
Top Width (B), Hydraulic Radius (R), Hydraulic Depth (D), Flow Mean Velocity
(V), Flow Discharge (Q), Manning's roughness coefficient (n), Slope (Sf),
Temperature, Absolute Temperature, Saturated Liquid Density, Absolute or
Dynamic Viscosity, Kinematic Viscosity, Froude number (Fr), Reynolds number
(Re), symmetric side slope (m), non-symmetric side slope (m1), non-symmetric
side slope (m2), Section Factor (Z), conveyance (K), Specific Energy (E),
Velocity Head (Vel_Head), Maximum Shear Stress (taud), Average Shear Stress
(tau0) along with the associated units can be returned in a data.table.
Assumptions: uniform flow, prismatic channel, and surface water temperature of 20 degrees Celsius (68 degrees Fahrenheit) at atmospheric pressure
Note: Units must be consistent
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 2, 8, 36, 102, 120, 153-154.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Gilberto E. Urroz, Utah State University Civil and Environmental Engineering - OCW, CEE6510 - Numerical Methods in Civil Engineering, Spring 2006 (2006). Course 3. "Solving selected equations and systems of equations in hydraulics using Matlab", August/September 2004, https://digitalcommons.usu.edu/ocw_cee/3/.
Tyler G. Hicks, P.E., Civil Engineering Formulas: Pocket Guide, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2002, pages 423, 425.
Wikimedia Foundation, Inc. Wikipedia, 26 November 2015, "Manning formula", https://en.wikipedia.org/wiki/Manning_formula.
John C. Crittenden, R. Rhodes Trussell, David W. Hand, Kerry J. Howe, George Tchobanoglous, MWH's Water Treatment: Principles and Design, Third Edition, Hoboken, New Jersey: John Wiley & Sons, Inc., 2012, pages 1861-1862.
Andrew Chadwick, John Morfett and Martin Borthwick, Hydraulics in Civil and Environmental Engineering, Fourth Edition, New York City, New York: Spon Press, Inc., 2004, page 133.
Robert L. Mott and Joseph A. Untener, Applied Fluid Mechanics, Seventh Edition, New York City, New York: Pearson, 2015, pages 376, 393.
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 21, 40-41.
Gary P. Merkley, "BIE6300 - Irrigation & Conveyance Control Systems, Spring 2004", 2004, Biological and Irrigation Engineering - OCW. Course 2, https://digitalcommons.usu.edu/ocw_bie/2/.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
Wikimedia Foundation, Inc. Wikipedia, 15 May 2019, "Conversion of units", https://en.wikipedia.org/wiki/Conversion_of_units.
Manningtrap for a triangleal cross-section, Manningrect for a
rectangular cross-section, Manningpara for a parabolic cross-section,
Manningcirc for a circular cross-section, and Manning for the wrapper function.
install.load::load_package("iemisc", "iemiscdata") # Practice Problem 14.41 from Mott (page 393) # See nchannel in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Excavated or Dredged Channels, 3) # Earth, straight, and uniform, 4) clean, recently completed. data(nchannel) nlocation <- grep("clean, recently completed", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningtri(Q = 0.68, m = 1.5, Sf = 0.0023, n = n, units = "Eng", type = "symmetrical", output = "list") # Q = 0.68 cfs, m = 1.5, Sf = 0.002 ft/ft, n = 0.05, units = English units # This will solve for y since it is missing and y will be in ft # Modified Exercise 4.1 from Sturm (page 153) Manningtri(Q = 3000, m = 3, Sf = 0.002, n = 0.025, units = "Eng", type = "symmetrical", output = "list") # Q = 3000 cfs, m = 3, Sf = 0.002 ft/ft, n = 0.025, units = English units # This will solve for y since it is missing and y will be in ft # Modified Exercise 4.5 from Sturm (page 154) Manningtri(Q = 950, m = 2, Sf = 0.022, n = 0.023, units = "SI", type = "symmetrical", output = "data.table") # Q = 950 m^3/s, m = 2, Sf = 0.022 m/m, n = 0.023, units = SI units # This will solve for y since it is missing and y will be in minstall.load::load_package("iemisc", "iemiscdata") # Practice Problem 14.41 from Mott (page 393) # See nchannel in iemiscdata for the Manning's n table that the # following example uses # Use the normal Manning's n value for 1) Natural streams - minor streams # (top width at floodstage < 100 ft), 2) Excavated or Dredged Channels, 3) # Earth, straight, and uniform, 4) clean, recently completed. data(nchannel) nlocation <- grep("clean, recently completed", nchannel$"Type of Channel and Description") n <- as.numeric(nchannel[nlocation, 3]) # 3 for column 3 - Normal n Manningtri(Q = 0.68, m = 1.5, Sf = 0.0023, n = n, units = "Eng", type = "symmetrical", output = "list") # Q = 0.68 cfs, m = 1.5, Sf = 0.002 ft/ft, n = 0.05, units = English units # This will solve for y since it is missing and y will be in ft # Modified Exercise 4.1 from Sturm (page 153) Manningtri(Q = 3000, m = 3, Sf = 0.002, n = 0.025, units = "Eng", type = "symmetrical", output = "list") # Q = 3000 cfs, m = 3, Sf = 0.002 ft/ft, n = 0.025, units = English units # This will solve for y since it is missing and y will be in ft # Modified Exercise 4.5 from Sturm (page 154) Manningtri(Q = 950, m = 2, Sf = 0.022, n = 0.023, units = "SI", type = "symmetrical", output = "data.table") # Q = 950 m^3/s, m = 2, Sf = 0.022 m/m, n = 0.023, units = SI units # This will solve for y since it is missing and y will be in m
This function computes the maximum mean relative error (MAXRE).
maxmre(predicted, observed, na.rm = FALSE)maxmre(predicted, observed, na.rm = FALSE)
predicted |
numeric vector that contains the model predicted data points (1st parameters) |
observed |
numeric vector that contains the observed data points (2nd parameters) |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
(MAXRE) is expressed as
the number of observations
the predicted values
the observed or reference values
maximum mean relative error (MAXRE) as a numeric vector using the same
units as the given variables. The default choice is that any NA values
will be kept (na.rm = FALSE). This can be changed by
specifying na.rm = TRUE, such as maxmre(pre, obs, na.rm = TRUE).
Irucka Embry
Huang, J. (2018). "A Simple Accurate Formula for Calculating Saturation Vapor Pressure of Water and Ice", Journal of Applied Meteorology and Climatology, 57(6), 1265-1272. Retrieved Nov 4, 2021, https://web.archive.org/web/20221024040058/https://journals.ametsoc.org/view/journals/apme/57/6/jamc-d-17-0334.1.xml. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
mape for mean absolute percent error (MAPE), madstat for
mean-absolute deviation (MAD), dr for "index of agreement (dr)", vnse
for Nash-Sutcliffe model efficiency (NSE), rmse for
root mean square error (RMSE), and mre for the mean relative
error (MRE).
# Example 1 library(iemisc) obs <- 1:10 # observed pre <- 2:11 # predicted maxmre(pre, obs) # Example 2 install.load::load_package("iemisc", "rando", "data.table") set_n(100) # makes the example reproducible obs1 <- r_norm(.seed = 605) # observed pre1 <- r_norm(.seed = 364) # predicted # using the vectors pre1 and obs1 maxmre(pre1, obs1) # using a matrix of the numeric vectors pre1 and obs1 mat1 <- matrix(data = c(obs1, pre1), nrow = length(pre1), ncol = 2, byrow = FALSE, dimnames = list(c(rep("", length(pre1))), c("Predicted", "Observed"))) maxmre(mat1[, 2], mat1[, 1]) # mat1[, 1] # observed values from column 1 of mat1 # mat1[, 2] # predicted values from column 2 of mat1 # using a data.frame of the numeric vectors pre1 and obs1 df1 <- data.frame(obs1, pre1) maxmre(df1[, 2], df1[, 1]) # df1[, 1] # observed values from column 1 of df1 # df1[, 2] # predicted values from column 2 of df1 # using a data.table of the numeric vectors pre1 and obs1 df2 <- data.table(obs1, pre1) maxmre(df2[, 2, with = FALSE][[1]], df2[, 1, with = FALSE][[1]]) # df2[, 1, with = FALSE][[1]] # observed values from column 1 of df2 # df2[, 2, with = FALSE][[1]] # predicted values from column 2 of df2# Example 1 library(iemisc) obs <- 1:10 # observed pre <- 2:11 # predicted maxmre(pre, obs) # Example 2 install.load::load_package("iemisc", "rando", "data.table") set_n(100) # makes the example reproducible obs1 <- r_norm(.seed = 605) # observed pre1 <- r_norm(.seed = 364) # predicted # using the vectors pre1 and obs1 maxmre(pre1, obs1) # using a matrix of the numeric vectors pre1 and obs1 mat1 <- matrix(data = c(obs1, pre1), nrow = length(pre1), ncol = 2, byrow = FALSE, dimnames = list(c(rep("", length(pre1))), c("Predicted", "Observed"))) maxmre(mat1[, 2], mat1[, 1]) # mat1[, 1] # observed values from column 1 of mat1 # mat1[, 2] # predicted values from column 2 of mat1 # using a data.frame of the numeric vectors pre1 and obs1 df1 <- data.frame(obs1, pre1) maxmre(df1[, 2], df1[, 1]) # df1[, 1] # observed values from column 1 of df1 # df1[, 2] # predicted values from column 2 of df1 # using a data.table of the numeric vectors pre1 and obs1 df2 <- data.table(obs1, pre1) maxmre(df2[, 2, with = FALSE][[1]], df2[, 1, with = FALSE][[1]]) # df2[, 1, with = FALSE][[1]] # observed values from column 1 of df2 # df2[, 2, with = FALSE][[1]] # predicted values from column 2 of df2
Obtain the modulo of x and y in a manner compatible with GNU Octave/MATLAB.
Mod_octave(x, n)Mod_octave(x, n)
x, n
|
An R object (array, matrix, vector) |
Return the computed modulo of x and y.
Irucka Embry, Samit Basu (FreeMat)
Samit Basu (2002-2006). FreeMat v4.0, ‘https://freemat.sourceforge.net/help/mathfunctions_mod.html’.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. ‘https://docs.octave.org/octave.pdf’. Page 564.
# Example from FreeMat library(iemisc) Mod_octave(18, 12) # Please refer to the iemisc: Examples from GNU Octave Rem, Mod, and # fractdiff Compatible Functions vignette for additional examples# Example from FreeMat library(iemisc) Mod_octave(18, 12) # Please refer to the iemisc: Examples from GNU Octave Rem, Mod, and # fractdiff Compatible Functions vignette for additional examples
This function calculates the mortality rate which is also known as the crude death rate for a given population.
mortality_rate(number_people_dead, population_size, n)mortality_rate(number_people_dead, population_size, n)
number_people_dead |
numeric vector that contains the number of people dead for a time period |
population_size |
numeric vector that contains the total population size of which the deaths occurred |
n |
numeric vector that contains the population size units (ex., 3 for 1,000 people, 5 for 100,000 people) |
the mortality rate as a numeric vector
Irucka Embry
Giovanni Scerra, Published Sep 26, 2021, "The Math of the Pandemic: COVID-19 Mortality Rate", LinkedIn, https://www.linkedin.com/pulse/math-pandemic-covid-19-mortality-rate-giovanni-scerra-.
Michael Darcy and Łucja Zaborowska, MD, PhD, Last updated on Nov 05, 2022, "Mortality Rate Calculator", Omni Calculator, https://www.omnicalculator.com/health/mortality-rate.
# Example from Reference 1 library(iemisc) mortality_rate(369369, 331534662, 5)# Example from Reference 1 library(iemisc) mortality_rate(369369, 331534662, 5)
This function calculates the mortality rate percent which is also known as the crude death rate percent for a given population.
mortality_rate_pct(mortality_rate, n)mortality_rate_pct(mortality_rate, n)
mortality_rate |
numeric vector that contains the mortality rate |
n |
numeric vector that contains the population size units (ex., 3 for 1,000 people, 5 for 100,000 people) |
the mortality rate percent as a numeric vector
Irucka Embry
Giovanni Scerra, Published Sep 26, 2021, "The Math of the Pandemic: COVID-19 Mortality Rate", LinkedIn, https://www.linkedin.com/pulse/math-pandemic-covid-19-mortality-rate-giovanni-scerra-.
Michael Darcy and Łucja Zaborowska, MD, PhD, Last updated on Nov 05, 2022, "Mortality Rate Calculator", Omni Calculator, https://www.omnicalculator.com/health/mortality-rate.
# Example from Reference 1 library(iemisc) mr_2020 <- mortality_rate(369369, 331534662, 5) mortality_rate_pct(mortality_rate(15, 331534662, 5), 5) mortality_rate_pct(mr_2020, 5) mortality_rate_pct(15, 5)# Example from Reference 1 library(iemisc) mr_2020 <- mortality_rate(369369, 331534662, 5) mortality_rate_pct(mortality_rate(15, 331534662, 5), 5) mortality_rate_pct(mr_2020, 5) mortality_rate_pct(15, 5)
This function computes the mean relative error (MRE).
mre(predicted, observed, na.rm = FALSE)mre(predicted, observed, na.rm = FALSE)
predicted |
numeric vector that contains the model predicted data points (1st parameters) |
observed |
numeric vector that contains the observed data points (2nd parameters) |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
(MRE) is expressed as
the number of observations
the predicted values
the observed or reference values
mean relative error (MRE) as a numeric vector using the same
units as the given variables. The default choice is that any NA values
will be kept (na.rm = FALSE). This can be changed by
specifying na.rm = TRUE, such as mre(pre, obs, na.rm = TRUE).
Irucka Embry
Huang, J. (2018). "A Simple Accurate Formula for Calculating Saturation Vapor Pressure of Water and Ice", Journal of Applied Meteorology and Climatology, 57(6), 1265-1272. Retrieved Nov 4, 2021, https://web.archive.org/web/20221024040058/https://journals.ametsoc.org/view/journals/apme/57/6/jamc-d-17-0334.1.xml. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
mape for mean absolute percent error (MAPE), madstat for
mean-absolute deviation (MAD), dr for 'index of agreement (dr)', vnse
for Nash-Sutcliffe model efficiency (NSE), rmse for
root mean square error (RMSE), and maxmre for the maximum mean
relative error (MAXRE).
# Example 1 library(iemisc) obs <- 1:10 # observed pre <- 2:11 # predicted mre(pre, obs) # Example 2 install.load::load_package("iemisc", "rando") set_n(100) # makes the example reproducible obs1 <- r_norm(.seed = 873) # observed pre1 <- r_norm(.seed = 281) # predicted # using the vectors pre1 and obs1 mre(pre1, obs1) # using a matrix of the numeric vectors pre1 and obs1 mat1 <- matrix(data = c(obs1, pre1), nrow = length(pre1), ncol = 2, byrow = FALSE, dimnames = list(c(rep("", length(pre1))), c("Predicted", "Observed"))) mre(mat1[, 2], mat1[, 1]) # mat1[, 1] # observed values from column 1 of mat1 # mat1[, 2] # predicted values from column 2 of mat1 # using a data.frame of the numeric vectors pre1 and obs1 df1 <- data.frame(obs1, pre1) mre(df1[, 2], df1[, 1]) # df1[, 1] # observed values from column 1 of df1 # df1[, 2] # predicted values from column 2 of df1 library(data.table) # using a data.table of the numeric vectors pre1 and obs1 df2 <- data.table(obs1, pre1) mre(df2[, 2, with = FALSE][[1]], df2[, 1, with = FALSE][[1]]) # df2[, 1, with = FALSE][[1]] # observed values from column 1 of df2 # df2[, 2, with = FALSE][[1]] # predicted values from column 2 of df2# Example 1 library(iemisc) obs <- 1:10 # observed pre <- 2:11 # predicted mre(pre, obs) # Example 2 install.load::load_package("iemisc", "rando") set_n(100) # makes the example reproducible obs1 <- r_norm(.seed = 873) # observed pre1 <- r_norm(.seed = 281) # predicted # using the vectors pre1 and obs1 mre(pre1, obs1) # using a matrix of the numeric vectors pre1 and obs1 mat1 <- matrix(data = c(obs1, pre1), nrow = length(pre1), ncol = 2, byrow = FALSE, dimnames = list(c(rep("", length(pre1))), c("Predicted", "Observed"))) mre(mat1[, 2], mat1[, 1]) # mat1[, 1] # observed values from column 1 of mat1 # mat1[, 2] # predicted values from column 2 of mat1 # using a data.frame of the numeric vectors pre1 and obs1 df1 <- data.frame(obs1, pre1) mre(df1[, 2], df1[, 1]) # df1[, 1] # observed values from column 1 of df1 # df1[, 2] # predicted values from column 2 of df1 library(data.table) # using a data.table of the numeric vectors pre1 and obs1 df2 <- data.table(obs1, pre1) mre(df2[, 2, with = FALSE][[1]], df2[, 1, with = FALSE][[1]]) # df2[, 1, with = FALSE][[1]] # observed values from column 1 of df2 # df2[, 2, with = FALSE][[1]] # predicted values from column 2 of df2
This function computes Manning's n for natural channels.
n(nb = NULL, n1 = NULL, n2 = NULL, n3 = NULL, n4 = NULL, m = NULL)n(nb = NULL, n1 = NULL, n2 = NULL, n3 = NULL, n4 = NULL, m = NULL)
nb |
numeric vector that contains "the base value for a straight, uniform channel", if needed |
n1 |
numeric vector that contains "correction for surface irregularities", if needed |
n2 |
numeric vector that contains "correction for variations in the shape and size of the cross section", if needed |
n3 |
numeric vector that contains "correction for obstructions", if needed |
n4 |
numeric vector that contains "correction for vegetation and flow conditions", if needed |
m |
numeric vector that contains "correction factor for channel meandering", if needed |
"Roughness values for channels and flood plains should be determined separately. The composition, physical shape, and vegetation of a flood plain can be quite different from those of a channel." Source: USGS.
The equation to find Manning's n for natural channels is expressed as
Manning's n
"the base value for a straight, uniform channel"
"correction for surface irregularities"
"correction for variations in the shape and size of the cross section"
"correction for obstructions"
"correction for vegetation and flow conditions"
"correction factor for channel meandering"
Source: Sturm page 114.
n as Manning's n for a natural channel as a numeric vector.
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, page 114.
Guide for Selecting Manning's Roughness Coefficients for Natural Channels and Flood Plains, United States Geological Survey Water-supply Paper 2339 Metric Version
George J. Arcement, Jr., and Verne R. Schneider, United States Geological Survey Water-Supply Paper 2339, "Guide for Selecting Manning's Roughness Coefficients for Natural Channels and Flood Plains", 1989, https://pubs.usgs.gov/wsp/2339/report.pdf.
nc1 for Horton method for composite Manning's n, nc2 for
Einstein and Banks method for composite Manning's n, nc3 for
Lotter method for composite Manning's n, and nc4 for
Krishnamurthy and Christensen method for composite Manning's n.
library(iemisc) # Example from Table 4. from the USGS Reference text page 35 n(nb = 0.025, n4 = 0.005, m = 1.00)library(iemisc) # Example from Table 4. from the USGS Reference text page 35 n(nb = 0.025, n4 = 0.005, m = 1.00)
This function combines pracma's interp1
constant interpolation method with zoo's na.approx linear
interpolation method. Here, x = x rather than
x = index(object) in na.approx. Here, y = y rather than
y = object in na.approx. Also, here, xi is used instead
of xout in na.approx. The Arguments list was obtained from both
interp1 and na.approx.
na.interp1(x, y, xi = x, ..., na.rm = TRUE, maxgap = Inf)na.interp1(x, y, xi = x, ..., na.rm = TRUE, maxgap = Inf)
x |
numeric vector; points on the x-axis; at least two points required; will be sorted if necessary. |
y |
numeric vector; values of the assumed underlying function;
|
xi |
numeric vector; points at which to compute the
interpolation; all points must lie between |
... |
further arguments passed to methods. The |
na.rm |
logical. If the result of the ( |
maxgap |
maximum number of consecutive |
Numeric vector representing values at points xi.
Hans Werner Borchers (pracma interp1), Felix Andrews (zoo na.approx), Irucka Embry
zoo's na.approx.R - modified on Fri Aug 6 00:26:22 2010 UTC by felix. See https://r-forge.r-project.org/scm/viewvc.php/pkg/zoo/R/na.approx.R?view=markup&revision=781&root=zoo.
pracma interp1 function definition - R package pracma created and maintained by Hans Werner Borchers. See interp1.
# zoo time series example install.load::load_package("iemisc", "data.table") zoo1 <- structure(c(1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 2, 2.1, 2.1, NA, NA, 2.1, 2.1, NA, 2.3, NA, 2, 2.1), .Dim = c(12L, 2L), .Dimnames = list(NULL, c("V1", "V2")), index = structure(c(1395242100, 1395243000, 1395243900, 1395244800, 1395245700, 1395256500, 1395257400, 1395258300, 1395259200, 1395260100, 1395261000, 1395261900), class = c("POSIXct", "POSIXt"), tzone = "GMT"), class = "zoo") zoo1 <- as.data.frame(zoo1) # to data.frame from zoo zoo1[, "Time"] <- as.POSIXct(rownames(zoo1)) # create column named Time as a # POSIXct class zoo1 <- setDT(zoo1) # create data.table out of data.frame setcolorder(zoo1, c(3, 1, 2)) # set the column order as the 3rd column # followed by the 2nd and 1st columns zoo1 <- setDF(zoo1) # return to data.frame rowsinterps1 <- which(is.na(zoo1$V2 == TRUE)) # index of rows of zoo1 that have NA (to be interpolated) xi <- as.numeric(zoo1[which(is.na(zoo1$V2 == TRUE)), 1]) # the Date-Times for V2 to be interpolated in numeric format interps1 <- na.interp1(as.numeric(zoo1$Time), zoo1$V2, xi = xi, na.rm = FALSE, maxgap = 1) # the interpolated values where only gap sizes of 1 are filled zoo1[rowsinterps1, 3] <- interps1 # replace the NAs in V2 with the interpolated V2 values zoo1 # data frame time series example library(iemisc) df1 <- structure(list(Time = structure(c(1395242100, 1395243000, 1395243900, 1395244800, 1395245700, 1395256500, 1395257400, 1395258300, 1395259200, 1395260100, 1395261000, 1395261900), class = c("POSIXct", "POSIXt"), tzone = "GMT"), V1 = c(1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 1.6, 1.7, 1.7, 1.7, 1.7, 1.7), V2 = c(2, 2.1, 2.1, NA, NA, 2.1, 2.1, NA, 2.3, NA, 2, 2.1)), .Names = c("Time", "V1", "V2"), row.names = c(NA, -12L), class = "data.frame") rowsinterps1 <- which(is.na(df1$V2 == TRUE)) # index of rows of df1 that have NA (to be interpolated) xi <- as.numeric(df1[which(is.na(df1$V2 == TRUE)), 1]) # the Date-Times for V2 to be interpolated in numeric format interps1 <- na.interp1(as.numeric(df1$Time), df1$V2, xi = xi, na.rm = FALSE, maxgap = 1) # the interpolated values where only gap sizes of 1 are filled df1[rowsinterps1, 3] <- interps1 # replace the NAs in V2 with the interpolated V2 values df1 # data.table time series example install.load::load_package("iemisc", "data.table") dt1 <- structure(list(Time = structure(c(1395242100, 1395243000, 1395243900, 1395244800, 1395245700, 1395256500, 1395257400, 1395258300, 1395259200, 1395260100, 1395261000, 1395261900), class = c("POSIXct", "POSIXt"), tzone = "GMT"), V1 = c(1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 1.6, 1.7, 1.7, 1.7, 1.7, 1.7), V2 = c(2, 2.1, 2.1, NA, NA, 2.1, 2.1, NA, 2.3, NA, 2, 2.1)), .Names = c("Time", "V1", "V2"), row.names = c(NA, -12L), class = c("data.table", "data.frame"), sorted = "Time") rowsinterps2 <- which(is.na(dt1[, 3, with = FALSE] == TRUE)) # index of rows of x that have NA (to be interpolated) xi <- as.numeric(dt1[rowsinterps2, Time]) # the Date-Times for V2 to be interpolated in numeric format interps2 <- dt1[, na.interp1(as.numeric(Time), V2, xi = xi, na.rm = FALSE, maxgap = 1)] # the interpolated values where only gap sizes of 1 are filled dt1[rowsinterps2, `:=` (V2 = interps2)] # replace the NAs in V2 with the interpolated V2 values dt1# zoo time series example install.load::load_package("iemisc", "data.table") zoo1 <- structure(c(1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 2, 2.1, 2.1, NA, NA, 2.1, 2.1, NA, 2.3, NA, 2, 2.1), .Dim = c(12L, 2L), .Dimnames = list(NULL, c("V1", "V2")), index = structure(c(1395242100, 1395243000, 1395243900, 1395244800, 1395245700, 1395256500, 1395257400, 1395258300, 1395259200, 1395260100, 1395261000, 1395261900), class = c("POSIXct", "POSIXt"), tzone = "GMT"), class = "zoo") zoo1 <- as.data.frame(zoo1) # to data.frame from zoo zoo1[, "Time"] <- as.POSIXct(rownames(zoo1)) # create column named Time as a # POSIXct class zoo1 <- setDT(zoo1) # create data.table out of data.frame setcolorder(zoo1, c(3, 1, 2)) # set the column order as the 3rd column # followed by the 2nd and 1st columns zoo1 <- setDF(zoo1) # return to data.frame rowsinterps1 <- which(is.na(zoo1$V2 == TRUE)) # index of rows of zoo1 that have NA (to be interpolated) xi <- as.numeric(zoo1[which(is.na(zoo1$V2 == TRUE)), 1]) # the Date-Times for V2 to be interpolated in numeric format interps1 <- na.interp1(as.numeric(zoo1$Time), zoo1$V2, xi = xi, na.rm = FALSE, maxgap = 1) # the interpolated values where only gap sizes of 1 are filled zoo1[rowsinterps1, 3] <- interps1 # replace the NAs in V2 with the interpolated V2 values zoo1 # data frame time series example library(iemisc) df1 <- structure(list(Time = structure(c(1395242100, 1395243000, 1395243900, 1395244800, 1395245700, 1395256500, 1395257400, 1395258300, 1395259200, 1395260100, 1395261000, 1395261900), class = c("POSIXct", "POSIXt"), tzone = "GMT"), V1 = c(1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 1.6, 1.7, 1.7, 1.7, 1.7, 1.7), V2 = c(2, 2.1, 2.1, NA, NA, 2.1, 2.1, NA, 2.3, NA, 2, 2.1)), .Names = c("Time", "V1", "V2"), row.names = c(NA, -12L), class = "data.frame") rowsinterps1 <- which(is.na(df1$V2 == TRUE)) # index of rows of df1 that have NA (to be interpolated) xi <- as.numeric(df1[which(is.na(df1$V2 == TRUE)), 1]) # the Date-Times for V2 to be interpolated in numeric format interps1 <- na.interp1(as.numeric(df1$Time), df1$V2, xi = xi, na.rm = FALSE, maxgap = 1) # the interpolated values where only gap sizes of 1 are filled df1[rowsinterps1, 3] <- interps1 # replace the NAs in V2 with the interpolated V2 values df1 # data.table time series example install.load::load_package("iemisc", "data.table") dt1 <- structure(list(Time = structure(c(1395242100, 1395243000, 1395243900, 1395244800, 1395245700, 1395256500, 1395257400, 1395258300, 1395259200, 1395260100, 1395261000, 1395261900), class = c("POSIXct", "POSIXt"), tzone = "GMT"), V1 = c(1.6, 1.7, 1.7, 1.7, 1.7, 1.7, 1.6, 1.7, 1.7, 1.7, 1.7, 1.7), V2 = c(2, 2.1, 2.1, NA, NA, 2.1, 2.1, NA, 2.3, NA, 2, 2.1)), .Names = c("Time", "V1", "V2"), row.names = c(NA, -12L), class = c("data.table", "data.frame"), sorted = "Time") rowsinterps2 <- which(is.na(dt1[, 3, with = FALSE] == TRUE)) # index of rows of x that have NA (to be interpolated) xi <- as.numeric(dt1[rowsinterps2, Time]) # the Date-Times for V2 to be interpolated in numeric format interps2 <- dt1[, na.interp1(as.numeric(Time), V2, xi = xi, na.rm = FALSE, maxgap = 1)] # the interpolated values where only gap sizes of 1 are filled dt1[rowsinterps2, `:=` (V2 = interps2)] # replace the NAs in V2 with the interpolated V2 values dt1
This function computes the composite Manning's n using the Horton method.
nc1(P, n)nc1(P, n)
P |
numeric vector that contains "wetted perimeters of any section i" |
n |
numeric vector that contains "Manning's n of any section i" |
"A composite value of Manning's n for a single channel; that is, for the main channel only of a compound channel or a canal with laterally varying roughness." Source: Sturm page 118.
The equation to find Manning's composite n using the Horton method is
Manning's composite n
"wetted perimeters of the entire cross section"
"wetted perimeters of any section i"
"Manning's n of any section i"
"total number of sections into which the wetted perimeters is divided"
Source: Sturm page 118.
numeric vector that contains nc1 as Manning's composite n.
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, page 118.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
n for Manning's n for natural channels, nc2 for
Einstein and Banks method for composite Manning's n, nc3 for
Lotter method for composite Manning's n, and nc4 for
Krishnamurthy and Christensen method for composite Manning's n.
library(iemisc) # Example from the Moore Reference text nc1(n = c(0.05, 0.035, 0.05, 0.04), P = c(22.22, 34.78, 2.00, 6.08))library(iemisc) # Example from the Moore Reference text nc1(n = c(0.05, 0.035, 0.05, 0.04), P = c(22.22, 34.78, 2.00, 6.08))
This function computes the composite Manning's n using the Einstein and Banks method.
nc2(P, n)nc2(P, n)
P |
numeric vector that contains "wetted perimeters of any section i" |
n |
numeric vector that contains "Manning's n of any section i" |
"A composite value of Manning's n for a single channel; that is, for the main channel only of a compound channel or a canal with laterally varying roughness." Source: Sturm page 118.
The equation to find Manning's composite n using the Einstein and Banks method is
Manning's composite n
"wetted perimeters of the entire cross section"
"wetted perimeters of any section i"
"Manning's n of any section i"
"total number of sections into which the wetted perimeters is divided"
Source: Sturm page 118.
numeric vector that contains nc2 as Manning's composite n.
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 118-119.
Dan Moore, P.E., NRCS Water Quality and Quantity Technology Development Team, Portland Oregon, "Using Mannings Equation with Natural Streams", August 2011, https://web.archive.org/web/20210416091858/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/xsec/manningsNaturally.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
n for Manning's n for natural channels, nc1 for
Horton method for composite Manning's n, nc3 for Lotter method for
composite Manning's n, and nc4 for Krishnamurthy and Christensen
method for composite Manning's n.
library(iemisc) # Example from the Moore Reference text nc2(n = c(0.05, 0.035, 0.05, 0.04), P = c(22.22, 34.78, 2.00, 6.08))library(iemisc) # Example from the Moore Reference text nc2(n = c(0.05, 0.035, 0.05, 0.04), P = c(22.22, 34.78, 2.00, 6.08))
This function computes the composite Manning's n using the Lotter method.
nc3(P, n, R)nc3(P, n, R)
P |
numeric vector that contains "wetted perimeters of any section i" |
n |
numeric vector that contains "Manning's n of any section i" |
R |
numeric vector that contains "hydraulic radius of any section i" |
"A composite value of Manning's n for a single channel; that is, for the main channel only of a compound channel or a canal with laterally varying roughness."
The equation to find Manning's composite n using the Lotter method is
Manning's composite n
"wetted perimeters of the entire cross section"
"hydraulic radius of the entire cross section"
"wetted perimeters of any section i"
"hydraulic radius of any section i"
"Manning's n of any section i"
"total number of sections into which the wetted perimeters and hydraulic radius are divided"
numeric vector that contains nc3 as Manning's composite n.
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 118-119.
n for Manning's n for natural channels, nc1
for Horton method for composite Manning's n, nc2 for
Einstein and Banks method for composite Manning's n, and nc4
for Krishnamurthy and Christensen method for composite Manning's n.
library(iemisc) nc3(n = c(0.0024, 0.035), P = c(23.65, 36.08), R = c(2.02, 6.23))library(iemisc) nc3(n = c(0.0024, 0.035), P = c(23.65, 36.08), R = c(2.02, 6.23))
This function computes the composite Manning's n using the Krishnamurthy and Christensen method.
nc4(P, n, y)nc4(P, n, y)
P |
numeric vector that contains "wetted perimeters of any section i" |
n |
numeric vector that contains "Manning's n of any section i" |
y |
numeric vector that contains "flow depth in the ith section" |
"A composite value of Manning's n for a single channel; that is, for the main channel only of a compound channel or a canal with laterally varying roughness."
The equation to find Manning's composite n using the Krishnamurthy and Christensen method is
Manning's composite n
"wetted perimeters of any section i"
"flow depth in the ith section"
"Manning's n of any section i"
"total number of sections into which the wetted perimeters and hydraulic radius are divided"
numeric vector that contains nc4 as Manning's composite n.
Irucka Embry
Terry W. Sturm, Open Channel Hydraulics, 2nd Edition, New York City, New York: The McGraw-Hill Companies, Inc., 2010, pages 118-119.
n for Manning's n for natural channels, nc1 for
Horton method for composite Manning's n, nc2 for Einstein and Banks
method for composite Manning's n, and nc3 for Lotter method for
composite Manning's n.
library(iemisc) nc4(n = c(0.0024, 0.035), P = c(23.65, 36.08), y = c(10.23, 7.38))library(iemisc) nc4(n = c(0.0024, 0.035), P = c(23.65, 36.08), y = c(10.23, 7.38))
Obtain the number of dimensions of an array [arrays, matrices, and vectors] in a manner compatible with GNU Octave/MATLAB.
ndims(x)ndims(x)
x |
An array (array, matrix, vector) |
"Return the number of dimensions of a. For any array, the result will always be greater than or equal to 2. Trailing singleton dimensions are not counted." Source: Eaton page 46.
Irucka Embry, Samit Basu (FreeMat)
Samit Basu (2002-2006). FreeMat v4.0, https://freemat.sourceforge.net/help/inspection_ndims.html.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 46.
library(iemisc) # Examples from GNU Octave ndims b <- matlab::ones(c(4, 1, 2, 1)) ndims(b)library(iemisc) # Examples from GNU Octave ndims b <- matlab::ones(c(4, 1, 2, 1)) ndims(b)
Compute n given P, F, and i
ngivenPFi(P, F, i)ngivenPFi(P, F, i)
P |
numeric vector that contains the present value(s) |
F |
numeric vector that contains the future value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
n is expressed as
the "number of interest periods"
the "future equivalent"
the "present equivalent"
the "effective interest rate per interest period"
n numeric vector that contains the period value(s)
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 129, 142.
# Example for equation 4-7 from the Reference text (page 142) library(iemisc) ngivenPFi(P = 500, F = 1000, i = 15)# Example for equation 4-7 from the Reference text (page 142) library(iemisc) ngivenPFi(P = 500, F = 1000, i = 15)
Obtain the number of elements of R objects [arrays, matrices, and vectors
(including lists)] in a manner compatible with GNU Octave/MATLAB. Some
documentation from length.
numel(x, ...)numel(x, ...)
x |
An R object (array, matrix, vector) |
... |
R objects (indices idx1, idx2, ...) |
"Return the number of elements in the R object x. Optionally, if indices idx1, idx2, ... are supplied, return the number of elements that would result from the indexing a(idx1, idx2, ...)." Source: Eaton page 41.
Irucka Embry, Samit Basu (FreeMat)
r - Add a Column to a Dataframe From a List of Values - Stack Overflow answered by Matthew Plourde on Jun 21 2012. See https://stackoverflow.com/questions/11130037/add-a-column-to-a-dataframe-from-a-list-of-values/11130178.
r - Why does is.vector() return TRUE for list? - Stack Overflow answered by Andrie on May 17 2011. See https://stackoverflow.com/questions/6032772/why-does-is-vector-return-true-for-list/6032909.
Samit Basu (2002-2006). FreeMat v4.0, https://freemat.sourceforge.net/help/inspection_numel.html.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Pages 46-47.
numel, numel, size, length, length_octave
library(iemisc) import::from(matlab, ones) xx <- list(1:26, 1:10) numel(xx)library(iemisc) import::from(matlab, ones) xx <- list(1:26, 1:10) numel(xx)
Compute P given A
PgivenA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) PA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )PgivenA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) PA( A, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
A |
numeric vector that contains the annual value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
P is expressed as
the "present equivalent"
the "uniform series amount (occurs at the end of each interest period)"
the "effective interest rate per interest period"
the "number of interest periods"
PgivenA numeric vector that contains the present value(s) rounded to 2 decimal places
PA data.table of both n (0 to n) and the resulting present values rounded to 2 decimal places
Irucka Embry
r - Convert column classes in data.table - Stack Overflow answered by Matt Dowle on Dec 27 2013. See https://stackoverflow.com/questions/7813578/convert-column-classes-in-data-table.
r - foreach loop not replicating traditional loop - Stack Overflow answered by F. Privé on Oct 19 2019. See https://stackoverflow.com/questions/58459665/r-foreach-loop-not-replicating-traditional-loop.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 133-134, 142, 164.
Dave Bruns, Exceljet: "Calculate original loan amount", https://exceljet.net/formulas/calculate-original-loan-amount.
library(iemisc) # Example 1 -- Example 4-9 from the Sullivan Reference text (pages 133-134) PgivenA(A = 20000, n = 5, i = 15, frequency = "annual") # the interest rate is 15% PA(20000, 5, 15, "annual") # the interest rate is 15% # Example 2 PgivenA(A = 93.22, n = 5, i = 4.50, frequency = "month") # Using LibreOffice Calc 6.1.5.2 version # A1 4.50% # A2 -93.22 # A3 60 # A4 12 # A5 =PV(A1/A4,A3,A2) = $5,000.26library(iemisc) # Example 1 -- Example 4-9 from the Sullivan Reference text (pages 133-134) PgivenA(A = 20000, n = 5, i = 15, frequency = "annual") # the interest rate is 15% PA(20000, 5, 15, "annual") # the interest rate is 15% # Example 2 PgivenA(A = 93.22, n = 5, i = 4.50, frequency = "month") # Using LibreOffice Calc 6.1.5.2 version # A1 4.50% # A2 -93.22 # A3 60 # A4 12 # A5 =PV(A1/A4,A3,A2) = $5,000.26
Compute P given A1
PgivenA1(A1, i, f, n)PgivenA1(A1, i, f, n)
A1 |
numeric vector that contains the initial annual value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
f |
numeric vector that contains the average interest rate value(s) as a percent per period |
n |
numeric vector that contains the period value(s) |
P is expressed as
or
"the present equivalent of the geometric gradient series"
"the initial cash flow in that occurs at the end of period one"
the "interest rate per period"
the "average rate each period"
the "number of interest periods"
Note: "f can be positive or negative"
PgivenA1 numeric vector that contains the present value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 156-159.
library(iemisc) # Example 4-23 from the Reference text (pages 158-159) PgivenA1(A1 = 1000, i = 25, f = 20, n = 4) # i is 25\% and f is 20\% # Example 4-24 from the Reference text (page 159) PgivenA1(A1 = 1000, i = 25, f = -20, n = 4) # i is 25\% and f is -20\%library(iemisc) # Example 4-23 from the Reference text (pages 158-159) PgivenA1(A1 = 1000, i = 25, f = 20, n = 4) # i is 25\% and f is 20\% # Example 4-24 from the Reference text (page 159) PgivenA1(A1 = 1000, i = 25, f = -20, n = 4) # i is 25\% and f is -20\%
Compute P given A with interest compounded continuously
PgivenAcont(A, n, r)PgivenAcont(A, n, r)
A |
numeric vector that contains the annual value(s) |
n |
numeric vector that contains the period value(s) |
r |
numeric vector that contains the continuously compounded nominal annual interest rate(s) as a percent |
P is expressed as
the "present equivalent"
the "annual equivalent amount (occurs at the end of each year)"
the "nominal annual interest rate, compounded continuously"
the "number of periods (years)"
PgivenAcont numeric vector that contains the present value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 169.
library(iemisc) PgivenAcont(2000, 3, 12) # the interest rate is 12%library(iemisc) PgivenAcont(2000, 3, 12) # the interest rate is 12%
Compute P given F
PgivenF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) PF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )PgivenF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") ) PF( F, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
F |
numeric vector that contains the future value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
P is expressed as
the "present equivalent"
the "future equivalent"
the "effective interest rate per interest period"
the "number of interest periods"
PgivenF numeric vector that contains the present value(s) rounded to 2 decimal places
PF data.frame of both n (0 to n) and the resulting present values rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 128, 142, 164.
library(iemisc) # Example 4-4 from the Reference text (page 128) PgivenF(10000, 6, 8, "annual") # the interest rate is 8% PF(10000, 6, 8, "annual") # the interest rate is 8%library(iemisc) # Example 4-4 from the Reference text (page 128) PgivenF(10000, 6, 8, "annual") # the interest rate is 8% PF(10000, 6, 8, "annual") # the interest rate is 8%
Compute P given F with interest compounded continuously
PgivenFcont(F, n, r)PgivenFcont(F, n, r)
F |
numeric vector that contains the future value(s) |
n |
numeric vector that contains the period value(s) |
r |
numeric vector that contains the continuously compounded nominal annual interest rate(s) as a percent |
P is expressed as
the "present equivalent"
the "future equivalent"
the "nominal annual interest rate, compounded continuously"
the "number of periods (years)"
PgivenFcont numeric vector that contains the present value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 169.
library(iemisc) PgivenFcont(1000, 9, 7) # the interest rate is 7%library(iemisc) PgivenFcont(1000, 9, 7) # the interest rate is 7%
Compute P given F and i that varies
PgivenFivary(Fn, ik, k)PgivenFivary(Fn, ik, k)
Fn |
numeric vector that contains the future value(s) at the end of a period n |
ik |
numeric vector that contains the effective interest rate(s) per period as a percent for the kth period |
k |
numeric vector that contains the kth period values |
P is expressed as
the "present equivalent"
the "future cash flows subject to varying interest rates"
the "interest rate for the kth period"
the "number of interest periods"
PgivenFivary numeric vector that contains the present value(s)
Irucka Embry
r - Add a Column to a Dataframe From a List of Values - Stack Overflow answered by Matthew Plourde on Jun 21 2012. See https://stackoverflow.com/questions/11130037/add-a-column-to-a-dataframe-from-a-list-of-values/11130178.
r - Why does is.vector() return TRUE for list? - Stack Overflow answered by Andrie on May 17 2011. See https://stackoverflow.com/questions/6032772/why-does-is-vector-return-true-for-list/6032909.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 142, 162.
library(iemisc) # Example for equation 4-31 from the Reference text (page 162) PgivenFivary(Fn = 1000, ik = c(10, 12, 13, 10), k = 1) # i1 is 10\%, i2 is 12\%, i3 is 14\%, and i4 is 10\% & k = 1 yearlibrary(iemisc) # Example for equation 4-31 from the Reference text (page 162) PgivenFivary(Fn = 1000, ik = c(10, 12, 13, 10), k = 1) # i1 is 10\%, i2 is 12\%, i3 is 14\%, and i4 is 10\% & k = 1 year
Compute P given G
PgivenG( G, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )PgivenG( G, n, i, frequency = c("annual", "semiannual", "quarter", "bimonth", "month", "daily") )
G |
numeric vector that contains the gradient value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as a percent |
frequency |
character vector that contains the frequency used to obtain the number of periods [annual (1), semiannual (2), quarter (4), bimonth (6), month (12), daily (365)] |
the "present equivalent"
the "uniform gradient amount"
the "effective interest rate per interest period"
the "number of interest periods"
PgivenG numeric vector that contains the present value(s) rounded to 2 decimal places
Irucka Embry
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, pages 142, 150, 152-154.
library(iemisc) # Example 4-20 from the Reference text (pages 153-154) PgivenG(1000, 4, 15, "annual") # the interest rate is 15%library(iemisc) # Example 4-20 from the Reference text (pages 153-154) PgivenG(1000, 4, 15, "annual") # the interest rate is 15%
Calculate the area of a polygon using the shoelace formula.
polygon_area(x, y, plot = c(0, 1), fill = NULL, color = NULL)polygon_area(x, y, plot = c(0, 1), fill = NULL, color = NULL)
x |
numeric vector that contains the x coordinates of the vertices. Regardless of rather the user starts in a clockwise or a counter-clockwise direction, the result will be positive. |
y |
numeric vector that contains the y coordinates of the vertices. Regardless of rather the user starts in a clockwise or a counter-clockwise direction, the result will be positive. |
plot |
integer vector that contains 0, 1 only. 0 represents do not plot the polygon and 1 is for plotting the polygon. |
fill |
character vector that contains the inside color of the polygon. The possible colors are those that are accepted by ggplot2. The default fill color is black. |
color |
character vector that the border color of the polygon. The possible colors are those that are accepted by ggplot2. The default fill color is black. |
the area of the polygon as a positive numeric vector.
John D Page for the JavaScript code, Irucka Embry (R code)
John D Page, From Math Open Reference: Algorithm to find the area of a polygon. See https://web.archive.org/web/20221006001150/https://www.mathopenref.com/coordpolygonarea2.html. Provided by Internet Archive: Wayback Machine to avoid the connection timeout.
# Example 1 from Source 2 library(iemisc) x <- c(4, 4, 8, 8, -4, -4) y <- c(6, -4, -4, -8, -8, 6) polygon_area(x, y, plot = 1) # compare with pracma's and geometry's polyarea pracma::polyarea(x, y) geometry::polyarea(x, y) # Example 2 library(iemisc) type38 <- construction_decimal("46'-10 1/2\"", decimal = "traditional", output = "vector") x38 <- c(0, 25, sum(25, type38, 10), sum(25, type38, 10, 25)) y38 <- c(0, rep((3 + 1 / 3), 2), 0) polygon_area(x38, y38, plot = 1, fill = "darkseagreen3", color = "aquamarine4") # compare with pracma's and geometry's polyarea pracma::polyarea(x38, y38) geometry::polyarea(x38, y38) # Example 3 install.load::load_package("iemisc", "data.table") coords <- fread(" X, Y 0, 0 34, 4 58, 4 84, 6.7 184, 0", header = TRUE) polygon_area(coords$X, coords$Y, plot = 1, color = "#00abff", fill = NA) # "Use NA for a completely transparent colour." (from ggplot2 color function) # compare with pracma's and geometry's polyarea pracma::polyarea(coords$X, coords$Y) geometry::polyarea(coords$X, coords$Y) # Example 4 from pracma library(iemisc) Xx <- c(0, 4, 4, 0) Yy <- c(0, 0, 4, 4) polygon_area(Xx, Yy, 1, color = "goldenrod1", fill = "#00abff") # compare with pracma's and geometry's polyarea pracma::polyarea(Xx, Yy) geometry::polyarea(Xx, Yy) # Example 5 from pracma library(iemisc) Xx1 <- c(0, 4, 2) Yy1 <- c(0, 0, 4) polygon_area(Xx1, Yy1, 1, color = "rosybrown", fill = "papayawhip") # compare with pracma's and geometry's polyarea pracma::polyarea(Xx1, Yy1) geometry::polyarea(Xx1, Yy1)# Example 1 from Source 2 library(iemisc) x <- c(4, 4, 8, 8, -4, -4) y <- c(6, -4, -4, -8, -8, 6) polygon_area(x, y, plot = 1) # compare with pracma's and geometry's polyarea pracma::polyarea(x, y) geometry::polyarea(x, y) # Example 2 library(iemisc) type38 <- construction_decimal("46'-10 1/2\"", decimal = "traditional", output = "vector") x38 <- c(0, 25, sum(25, type38, 10), sum(25, type38, 10, 25)) y38 <- c(0, rep((3 + 1 / 3), 2), 0) polygon_area(x38, y38, plot = 1, fill = "darkseagreen3", color = "aquamarine4") # compare with pracma's and geometry's polyarea pracma::polyarea(x38, y38) geometry::polyarea(x38, y38) # Example 3 install.load::load_package("iemisc", "data.table") coords <- fread(" X, Y 0, 0 34, 4 58, 4 84, 6.7 184, 0", header = TRUE) polygon_area(coords$X, coords$Y, plot = 1, color = "#00abff", fill = NA) # "Use NA for a completely transparent colour." (from ggplot2 color function) # compare with pracma's and geometry's polyarea pracma::polyarea(coords$X, coords$Y) geometry::polyarea(coords$X, coords$Y) # Example 4 from pracma library(iemisc) Xx <- c(0, 4, 4, 0) Yy <- c(0, 0, 4, 4) polygon_area(Xx, Yy, 1, color = "goldenrod1", fill = "#00abff") # compare with pracma's and geometry's polyarea pracma::polyarea(Xx, Yy) geometry::polyarea(Xx, Yy) # Example 5 from pracma library(iemisc) Xx1 <- c(0, 4, 2) Yy1 <- c(0, 0, 4) polygon_area(Xx1, Yy1, 1, color = "rosybrown", fill = "papayawhip") # compare with pracma's and geometry's polyarea pracma::polyarea(Xx1, Yy1) geometry::polyarea(Xx1, Yy1)
Takes Kentucky or Tennessee-based Northing and Easting engineering survey measurements [based in the State Plane Coordinate System (SPCS)] in meters, international foot, or US survey foot and converts those values into geodetic coordinates of the World Geodetic System (WGS) (19)84 (EPSG:4326). [MapTiler Reference] Each latitude [Y] and longitude [X] point is verified to be located within Kentucky or Tennessee.
project_midpoint( Northing_begin, Easting_begin, Northing_end, Easting_end, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("simple", "advanced") )project_midpoint( Northing_begin, Easting_begin, Northing_end, Easting_end, units = c("survey_ft", "foot", "meters"), location = c("KY", "TN"), output = c("simple", "advanced") )
Northing_begin |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting_begin |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Northing_end |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
Easting_end |
numeric vector (or character vector with numbers, commas, and decimal points) that contains the Northing engineering survey measurement in meters, international foot, or US survey foot |
units |
character vector that contains the system of units (options are
|
location |
character vector that contains the location name ('KY' for Kentucky or 'TN' for Tennessee) [only 1 location at a time] |
output |
character vector that contains simple for the default result
using a simple |
the projected associated latitude [Y] and longitude [X] mid point
coordinates in Decimal Degrees as a data.table or as an enhanced
data.table with the Northing and Easting coordinates in US
survey foot, international foot, and meters in addition to the [Y] and [X]
coordinates for the begin, middle, and end points
Please Note: If you have Kentucky North/South Zone survey measurements, then
please use the Kentucky Geological Survey, University of Kentucky - Kentucky
Single Coordinate Conversion Tool
(http://kgs.uky.edu/kgsweb/CoordConversionTool.asp) instead. That tool will
give you the geographic coordinates too. This R function, project_midpoint
will only be valid for NAD83 / Kentucky Single Zone.
Useful Tennessee reference Web site Tennessee Department of Transportation Roadway Design Survey Standards https://www.tn.gov/tdot/engineering-division/engineering-production-support/standard-drawings-library/standard-roadway-drawings/roadway-design-standards.html
Useful Kentucky reference Web site Kentucky Transportation Cabinet Survey Coordination https://transportation.ky.gov/Highway-Design/Pages/Survey-Coordination.aspx
Irucka Embry
Win-Vector Blog. John Mount, June 11, 2018, "R Tip: use isTRUE()", https://win-vector.com/2018/06/11/r-tip-use-istrue/.
Latitude Longitude Coordinates to State Code in R - Stack Overflow answered by Josh O'Brien on Jan 6 2012 and edited by Josh O'Brien on Jun 18, 2020. See https://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r.
r - Convert column classes in data.table - Stack Overflow answered by Matt Dowle on Dec 27 2013. See https://stackoverflow.com/questions/7813578/convert-column-classes-in-data-table.
Excel vlook up function in R for data frame - Stack Overflow answered by Tyler Rinker on Apr 8 2013 and edited by Tyler Rinker on Feb 26 2014. See https://stackoverflow.com/questions/15882743/excel-vlook-up-function-in-r-for-data-frame.
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.
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.
udunits.dat, v 1.18 2006/09/20 18:59:18 steve Exp, https://web.archive.org/web/20230202155021/https://www.unidata.ucar.edu/software/udunits/udunits-1/udunits.txt. Retrieved thanks to the Internet Archive: Wayback Machine
Spatial Reference, Aug. 13, 2004, "EPSG:3088: NAD83 / Kentucky Single Zone", https://spatialreference.org/ref/epsg/3088/.
Spatial Reference, March 7, 2000, "EPSG:32136 NAD83 / Tennessee", https://spatialreference.org/ref/epsg/32136/.
MapTiler Team, "EPSG:4326: WGS 84 – WGS84 - World Geodetic System 1984, used in GPS, https://epsg.io/4326.
Tennessee Department of Transportation Design Division, Tennessee Department of Transportation Tennessee Geodetic Reference Network (TGRN) Reference Manual Second Edition Issued, page ix, https://www.tn.gov/content/dam/tn/tdot/documents/TgrnComposite.pdf.
Earth Point, "State Plane Coordinate System - Convert, View on Google Earth", https://www.earthpoint.us/StatePlane.aspx.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, Mid Valley Oil Rad Relay Twr designation, HA1363 PID, Grayson County Kentucky, Clarkson (1967) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=HA1363.
National Geodetic Survey datasheet95, version 8.12.5.3, online retrieval date July 25, 2019, 2006 42 07 designation, DL4005 PID, Fayette County Kentucky, Lexington West (1993) USGS Quad, https://www.ngs.noaa.gov/cgi-bin/ds_mark.prl?PidBox=DL4005.
# Example 1 library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 project_midpoint(Northing_begin, Easting_begin, Northing_end, Easting_end, units = "survey_ft", location = "TN", output = "simple") # See Source 5 and Source 6 # Please see the error messages library(iemisc) # Tennessee (TN) Northing and Easting in meters Northing2 <- c(232489.480, 234732.431) Easting2 <- c(942754.124, 903795.239) dt4 <- try(project_midpoint(Northing2, Easting2, units = "survey_ft", location = "TN", output = "simple"))# Example 1 library(iemisc) Northing_begin <- 283715.8495 Easting_begin <- 1292428.3999 Northing_end <- 303340.6977 Easting_end <- 1295973.7743 project_midpoint(Northing_begin, Easting_begin, Northing_end, Easting_end, units = "survey_ft", location = "TN", output = "simple") # See Source 5 and Source 6 # Please see the error messages library(iemisc) # Tennessee (TN) Northing and Easting in meters Northing2 <- c(232489.480, 234732.431) Easting2 <- c(942754.124, 903795.239) dt4 <- try(project_midpoint(Northing2, Easting2, units = "survey_ft", location = "TN", output = "simple"))
This function calculates the proportional mortality ratio for a given population.
prop_mortality_ratio(cause_deaths, total_deaths)prop_mortality_ratio(cause_deaths, total_deaths)
cause_deaths |
numeric vector that contains the deaths from a single cause |
total_deaths |
numeric vector that contains the total deaths in the given population |
the proportional mortality ratio (as a percent) as a numeric vector
Irucka Embry
Michael Darcy and Łucja Zaborowska, MD, PhD, Last updated on Nov 05, 2022, "Mortality Rate Calculator", Omni Calculator, https://www.omnicalculator.com/health/mortality-rate. Florida Museum of Natural History: International Shark Attack File, Last updated on 07/19/2022, "Risk of Death: 18 Things More Likely to Kill You Than Sharks", https://www.floridamuseum.ufl.edu/shark-attacks/odds/compare-risk/death/. Farida B. Ahmad, MPH, Jodi A. Cisewski, MPH, Robert N. Anderson, PhD, MMWR Morb Mortal Wkly Rep 2022, 71:597-600, "Provisional Mortality Data — United States, 2021", https://www.cdc.gov/mmwr/volumes/71/wr/mm7117e1.htm.
# Data from Reference 2 and Reference 3 library(iemisc) prop_mortality_ratio(cause_deaths = 652486, total_deaths = 3458697) # annual heart disease deaths & total deaths in the US in 2021# Data from Reference 2 and Reference 3 library(iemisc) prop_mortality_ratio(cause_deaths = 652486, total_deaths = 3458697) # annual heart disease deaths & total deaths in the US in 2021
Solve the proportion for the missing numeric value in either of the numerators or denominators
prop_solver( n1 = NULL, d1 = NULL, n2 = NULL, d2 = NULL, output = c("single", "all") )prop_solver( n1 = NULL, d1 = NULL, n2 = NULL, d2 = NULL, output = c("single", "all") )
n1 |
numeric vector that contains the numerator 1 |
d1 |
numeric vector that contains the denominator 1 |
n2 |
numeric vector that contains the numerator 2 |
d2 |
numeric vector that contains the denominator 2 |
output |
character vector that contains the output type, (all or single) |
the missing proportion value as either a single numeric value or all values as characters
Irucka Embry
Basic Mathematics. "Solving Proportions", https://www.basic-mathematics.com/solving-proportions.html
Dr. Ariyana Love. "SMasks And Covid Tests Contain Nanotech Vaccines Without Informed Consent", April 7, 2021, https://ambassadorlove.blog/2021/04/07/masks-and-covid-tests-contain-nanotech-vaccines-without-informed-consent/
"Electronic Support for Public Health–Vaccine Adverse Event Reporting System (ESP:VAERS) Grant Final Report"/Grant ID: R18 HS 017045 [Inclusive dates: 12/01/07 - 09/30/10]. Principal Investigator: Lazarus, Ross, MBBS, MPH, MMed, GDCompSci., page 6, https://web.archive.org/web/20211230233658/https://www.nvic.org/CMSTemplates/NVIC/Pdf/FDA/ahrq-vaers-report-2011.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
# Example 1 from the Example # 1 from Reference 1 library(iemisc) # 5 / x = 10 / 16 prop_solver(n1 = 5, n2 = 10, d2 = 16, output = "single") # Example 2 library(iemisc) t1 <- "34 3 1/2" t2 <- 5 t3 <- 5 / 2 t11 <- construction_decimal(t1, decimal = "traditional", output = "vector") prop_solver(n1 = t11, n2 = 5, d1 = 5 / 2, output = "all") # Example 3 library(iemisc) # Let's assume that you have an item that you purchased for $4 and you wish # to sell the item at a consignment sale where you'll receive 75% of the # purchase price. In order to receive at minimum the $4, what should the # consignment sale price be? prop_solver(n1 = 4, n2 = 75/100, d2 = 1, output = "single") prop_solver(n2 = 75/100, d1 = 3, d2 = 1, output = "single") # Example 4 library(iemisc) # You have an image with a width of 840 pixels and a height of 1194 pixels & # you wish to reduce the image size by half while keeping the same resolution # & the same aspect ratio. What is the new height value in pixels? prop_solver(n1 = 840, n2 = 594, d1 = 1194, output = "single") # The n2 value was obtained from the # https://www.omnicalculator.com/other/resolution-scale online calculator. # Example 5 library(iemisc) # Refer to Reference 2 and Reference 3 # What is the numerator (n1) for the situation where VAERS reports 4,576 dead # people; however, the number of dead people is closer to 453,024 people? d1 <- 100 / 100 # 100% n2 <- 4576 # number of deceased people d2 <- 453024 # number of deceased people prop_solver(d1 = d1, n2 = n2, d2 = d2, output = "single") # What is the more accurate number of dead people (d2) where VAERS reports 4,576 # dead people and we recognize that less than 1% of adverse reactions are reported # to VAERS? n1 <- 0.99999999999999999999999999999999999999999999999 / 100 # less than 1% n11 <- 0.98 / 100 # less than 1% d1 <- 100 / 100 # number of deceased people n2 <- 4576 # number of deceased people prop_solver(n1 = n1, d1 = d1, n2 = n2, output = "all") prop_solver(n1 = n1, d1 = d1, n2 = n2, output = "single") prop_solver(n1 = n11, d1 = d1, n2 = n2, output = "all") prop_solver(n1 = n11, d1 = d1, n2 = n2, output = "single")# Example 1 from the Example # 1 from Reference 1 library(iemisc) # 5 / x = 10 / 16 prop_solver(n1 = 5, n2 = 10, d2 = 16, output = "single") # Example 2 library(iemisc) t1 <- "34 3 1/2" t2 <- 5 t3 <- 5 / 2 t11 <- construction_decimal(t1, decimal = "traditional", output = "vector") prop_solver(n1 = t11, n2 = 5, d1 = 5 / 2, output = "all") # Example 3 library(iemisc) # Let's assume that you have an item that you purchased for $4 and you wish # to sell the item at a consignment sale where you'll receive 75% of the # purchase price. In order to receive at minimum the $4, what should the # consignment sale price be? prop_solver(n1 = 4, n2 = 75/100, d2 = 1, output = "single") prop_solver(n2 = 75/100, d1 = 3, d2 = 1, output = "single") # Example 4 library(iemisc) # You have an image with a width of 840 pixels and a height of 1194 pixels & # you wish to reduce the image size by half while keeping the same resolution # & the same aspect ratio. What is the new height value in pixels? prop_solver(n1 = 840, n2 = 594, d1 = 1194, output = "single") # The n2 value was obtained from the # https://www.omnicalculator.com/other/resolution-scale online calculator. # Example 5 library(iemisc) # Refer to Reference 2 and Reference 3 # What is the numerator (n1) for the situation where VAERS reports 4,576 dead # people; however, the number of dead people is closer to 453,024 people? d1 <- 100 / 100 # 100% n2 <- 4576 # number of deceased people d2 <- 453024 # number of deceased people prop_solver(d1 = d1, n2 = n2, d2 = d2, output = "single") # What is the more accurate number of dead people (d2) where VAERS reports 4,576 # dead people and we recognize that less than 1% of adverse reactions are reported # to VAERS? n1 <- 0.99999999999999999999999999999999999999999999999 / 100 # less than 1% n11 <- 0.98 / 100 # less than 1% d1 <- 100 / 100 # number of deceased people n2 <- 4576 # number of deceased people prop_solver(n1 = n1, d1 = d1, n2 = n2, output = "all") prop_solver(n1 = n1, d1 = d1, n2 = n2, output = "single") prop_solver(n1 = n11, d1 = d1, n2 = n2, output = "all") prop_solver(n1 = n11, d1 = d1, n2 = n2, output = "single")
Calculate the number of pixels given the length and the resolution.
px(length, resolution, units = c("cm", "mm", "in"))px(length, resolution, units = c("cm", "mm", "in"))
length |
numeric vector that contains the length (inch, cm, or mm) |
resolution |
numeric vector that contains resolution (DPI or PPI) |
units |
character vector containing the unit for the length [default = in (inch)]. The other possible units are cm (centimeter) or mm (millimeter). |
the number of pixels as a numeric vector
"Note: PPI, Resolution and DPI are basically the same measurements. It's just that resolution or PPI (pixels per inch) are used on digital design or web while DPI (dots per inch) is a term used for printers and output devices. It's like saying 1px = 1dot." [Reference: Pixels]
Irucka Embry
Pixels Converter, "Inches to Pixels Converter", https://pixelsconverter.com/inches-to-pixels.
px(5, 300, units = "in") px(7, 300, units = "in") px(8, 300, units = "in") px(10, 300, units = "in") px(1/2, 300, units = "in") px(0.5, 300, units = "in") px("5 3/16", 96, units = "in") px(construction_measurement("5 3/16", decimal = "traditional", output = "vector", final = "decimal"), 96, units = "in") px(2.31, 548, units = "cm") px(23.1, 548, units = "mm")px(5, 300, units = "in") px(7, 300, units = "in") px(8, 300, units = "in") px(10, 300, units = "in") px(1/2, 300, units = "in") px(0.5, 300, units = "in") px("5 3/16", 96, units = "in") px(construction_measurement("5 3/16", decimal = "traditional", output = "vector", final = "decimal"), 96, units = "in") px(2.31, 548, units = "cm") px(23.1, 548, units = "mm")
Calculates the length given the number of pixels and the resolution.
px_length(px, resolution, units = c("cm", "mm", "in"))px_length(px, resolution, units = c("cm", "mm", "in"))
px |
numeric vector that contains the number of pixels |
resolution |
numeric vector that contains resolution (DPI or PPI) |
units |
character vector containing the unit for the length [default = in (inch)]. The other possible units are cm (centimeter) or mm (millimeter). |
the length in units of in (inch), cm (centimeter), or mm (millimeter).
"Note: PPI, Resolution and DPI are basically the same measurements. It's just that resolution or PPI (pixels per inch) are used on digital design or web while DPI (dots per inch) is a term used for printers and output devices. It's like saying 1px = 1dot." [Reference: Pixels]
Irucka Embry
Pixels Converter, "Pixels to Inches Converter", https://pixelsconverter.com/pixels-to-inches.
px_length(px(1/2, 300, units = "in"), 300, units = "in") px_length(px(0.5, 300, units = "in"), 300, units = "in") px_length(px("5 3/16", 96, units = "in"), 96, units = "in") px_length(px(construction_measurement("5 3/16", decimal = "traditional", output = "vector", final = "decimal"), 96, units = "in"), 96, units = "in") px_length(px(2.31, 548, units = "cm"), 548, units = "cm") px_length(px(23.1, 548, units = "mm"), 548, units = "mm")px_length(px(1/2, 300, units = "in"), 300, units = "in") px_length(px(0.5, 300, units = "in"), 300, units = "in") px_length(px("5 3/16", 96, units = "in"), 96, units = "in") px_length(px(construction_measurement("5 3/16", decimal = "traditional", output = "vector", final = "decimal"), 96, units = "in"), 96, units = "in") px_length(px(2.31, 548, units = "cm"), 548, units = "cm") px_length(px(23.1, 548, units = "mm"), 548, units = "mm")
This function computes the final rain garden dimensions based on the size of
the impervious roof surfaces and the initial rain garden size. This function
uses the surface_area values and units in the calculations.
rain_garden_driveway( dw_length = NULL, dw_width = NULL, rf_length = NULL, rf_width = NULL, driveway_table = NULL, roof_table = NULL, lw_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer"), rainfall_depth, rainfall_depth_units = c("inch", "feet", "centimeter", "meter"), rain_garden_depth, rain_garden_depth_units = c("inch", "feet", "centimeter", "meter") )rain_garden_driveway( dw_length = NULL, dw_width = NULL, rf_length = NULL, rf_width = NULL, driveway_table = NULL, roof_table = NULL, lw_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer"), rainfall_depth, rainfall_depth_units = c("inch", "feet", "centimeter", "meter"), rain_garden_depth, rain_garden_depth_units = c("inch", "feet", "centimeter", "meter") )
dw_length |
numeric vector containing the length value(s) in one of the lw_units values for the driveway(s). |
dw_width |
numeric vector containing the width value(s) in one of the lw_units values for the driveway(s). |
rf_length |
numeric vector containing the length value(s) in one of the lw_units values for the roof(s). |
rf_width |
numeric vector containing the width value(s) in one of the lw_units values for the roof(s). |
driveway_table |
data.frame/data.table/tibble, list, or matrix containing the length in column 1 and the width in column 2 for the driveway(s). |
roof_table |
data.frame/data.table/tibble, list, or matrix containing the length in column 1 and the width in column 2 for the roof(s). |
lw_units |
character vector containing the units for the length and the width (default = "feet"). The other possible units are "inch", "survey_foot", "yard", "mile", "centimeter", "meter", or "kilometer". The units should be consistent and not mixed. |
rainfall_depth |
numeric vector containing the rainfall depth in one of the rainfall_depth_units. |
rainfall_depth_units |
character vector containing the units for the rainfall depth (default = "feet"). The other possible units are "inch", "centimeter", or "meter". |
rain_garden_depth |
numeric vector containing the rain garden depth in one of the rain_garden_depth_units. |
rain_garden_depth_units |
character vector containing the units for the rain garden depth (default = "feet"). The other possible units are "inch", "centimeter", or "meter". |
a data.table with the following columns:
Driveway Drainage Area, One-Quarter of Roof Area, Depth of Rain, Design
Storm Volume, Rain Garden Depth, Rain Garden Initial Size, Rain Garden
Initial Dimensions, Total Drainage Area, New Design Storm Volume, Rain
Garden Final Size, Rain Garden Final Dimensions
Irucka Embry
r - Method to operate on each row of data.table without using apply function - Stack Overflow question posed by CuriousTim on Dec 10, 2017. See https://stackoverflow.com/questions/47737230/method-to-operate-on-each-row-of-data-table-without-using-apply-function.
Green Infrastructure Champion Training: Part 7: "How To Design and Build a Rain Garden", April 10, 2019, pages 41 - 43 of the PDF document, https://water.rutgers.edu/Projects/GreenInfrastructureChampions/Talks_2020/Part_7_04102020.pdf.
surface_area for calculating the linear surface area
# Note: the units must be consistent for the lengths and widths # Example 1 (from the Reference) library(iemisc) dw_width1 <- c(15, 10) dw_length1 <- c(50, 25) lw_units <- "feet" rf_width1 <- 50 rf_length1 <- 25 rainfall_depth1 <- 1.5 rainfall_depth_units <- "inch" rain_garden_depth <- 6 rain_garden_depth_units <- "inch" rain_garden_driveway(dw_length = dw_length1, dw_width = dw_width1, rf_length = rf_length1, rf_width = rf_width1, lw_units = lw_units, rainfall_depth = rainfall_depth1, rainfall_depth_units = rainfall_depth_units, rain_garden_depth = rain_garden_depth, rain_garden_depth_units = rain_garden_depth_units) # Example 2A # from https://www.ecoccs.com/R-Examples/Simple-Rain-Garden-Sizing_with-R.html # Irucka Embry modified the Example from the Reference for this example install.load::load_package("iemisc", "data.table") dw_length2 <- c("50 feet 3 1/2 inch", "25 feet 5 7/8 inch") dw_width2 <- c("15 feet 10 3/4 inch", "10 feet 7 3/8 inch") lw_units <- "feet" rf_length2 <- "25 feet 10 1/4 inch" rf_width2 <- construction_measurement("12.5 feet 1 1/8 inch", decimal = "traditional", output = "vector", final = "decimal") * 4 rainfall_depth2 <- 2.25 rainfall_depth_units <- "inch" rain_garden_depth <- 6 rain_garden_depth_units <- "inch" driveway_table <- data.table(length = dw_length2, width = dw_width2) roof_table <- data.table(length = rf_length2, width = rf_width2) rain_garden_driveway(driveway_table = driveway_table, roof_table = roof_table, lw_units = lw_units, rainfall_depth = rainfall_depth2, rainfall_depth_units = rainfall_depth_units, rain_garden_depth = rain_garden_depth, rain_garden_depth_units = rain_garden_depth_units) # Example 2B # from https://www.ecoccs.com/R-Examples/Simple-Rain-Garden-Sizing_with-R.html # Irucka Embry modified the Example from the Reference for this example install.load::load_package("iemisc", "data.table") dw_length3 <- c("50 feet 3 1/2 inch", "25 feet 5 7/8 inch") dw_width3 <- c("15 feet 10 3/4 inch", "10 feet 7 3/8 inch") lw_units <- "feet" rf_length3 <- "25 feet 10 1/4 inch" rf_width3 <- construction_measurement("12.5 feet 1 1/8 inch", decimal = "traditional", output = "vector", final = "decimal") * 4 rainfall_depth3 <- 2.25 rainfall_depth_units <- "inch" rain_garden_depth <- 6 rain_garden_depth_units <- "inch" driveway_table <- data.table(length = dw_length3, width = dw_width3) roof_table <- data.table(length = rf_length3, width = rf_width3) rain_garden_driveway(driveway_table = driveway_table, roof_table = roof_table, lw_units = lw_units, rainfall_depth = rainfall_depth2, rainfall_depth_units = rainfall_depth_units, rain_garden_depth = rain_garden_depth, rain_garden_depth_units = rain_garden_depth_units)# Note: the units must be consistent for the lengths and widths # Example 1 (from the Reference) library(iemisc) dw_width1 <- c(15, 10) dw_length1 <- c(50, 25) lw_units <- "feet" rf_width1 <- 50 rf_length1 <- 25 rainfall_depth1 <- 1.5 rainfall_depth_units <- "inch" rain_garden_depth <- 6 rain_garden_depth_units <- "inch" rain_garden_driveway(dw_length = dw_length1, dw_width = dw_width1, rf_length = rf_length1, rf_width = rf_width1, lw_units = lw_units, rainfall_depth = rainfall_depth1, rainfall_depth_units = rainfall_depth_units, rain_garden_depth = rain_garden_depth, rain_garden_depth_units = rain_garden_depth_units) # Example 2A # from https://www.ecoccs.com/R-Examples/Simple-Rain-Garden-Sizing_with-R.html # Irucka Embry modified the Example from the Reference for this example install.load::load_package("iemisc", "data.table") dw_length2 <- c("50 feet 3 1/2 inch", "25 feet 5 7/8 inch") dw_width2 <- c("15 feet 10 3/4 inch", "10 feet 7 3/8 inch") lw_units <- "feet" rf_length2 <- "25 feet 10 1/4 inch" rf_width2 <- construction_measurement("12.5 feet 1 1/8 inch", decimal = "traditional", output = "vector", final = "decimal") * 4 rainfall_depth2 <- 2.25 rainfall_depth_units <- "inch" rain_garden_depth <- 6 rain_garden_depth_units <- "inch" driveway_table <- data.table(length = dw_length2, width = dw_width2) roof_table <- data.table(length = rf_length2, width = rf_width2) rain_garden_driveway(driveway_table = driveway_table, roof_table = roof_table, lw_units = lw_units, rainfall_depth = rainfall_depth2, rainfall_depth_units = rainfall_depth_units, rain_garden_depth = rain_garden_depth, rain_garden_depth_units = rain_garden_depth_units) # Example 2B # from https://www.ecoccs.com/R-Examples/Simple-Rain-Garden-Sizing_with-R.html # Irucka Embry modified the Example from the Reference for this example install.load::load_package("iemisc", "data.table") dw_length3 <- c("50 feet 3 1/2 inch", "25 feet 5 7/8 inch") dw_width3 <- c("15 feet 10 3/4 inch", "10 feet 7 3/8 inch") lw_units <- "feet" rf_length3 <- "25 feet 10 1/4 inch" rf_width3 <- construction_measurement("12.5 feet 1 1/8 inch", decimal = "traditional", output = "vector", final = "decimal") * 4 rainfall_depth3 <- 2.25 rainfall_depth_units <- "inch" rain_garden_depth <- 6 rain_garden_depth_units <- "inch" driveway_table <- data.table(length = dw_length3, width = dw_width3) roof_table <- data.table(length = rf_length3, width = rf_width3) rain_garden_driveway(driveway_table = driveway_table, roof_table = roof_table, lw_units = lw_units, rainfall_depth = rainfall_depth2, rainfall_depth_units = rainfall_depth_units, rain_garden_depth = rain_garden_depth, rain_garden_depth_units = rain_garden_depth_units)
This function computes the sample range.
ranges(x, na.rm = FALSE, finite = FALSE)ranges(x, na.rm = FALSE, finite = FALSE)
x |
any numeric vector |
na.rm |
logical vector that determines whether the missing values should be removed or not. The default is FALSE. |
finite |
logical vector that determines whether non-finite values should be removed or not. The default is FALSE. |
"The range is the difference between the largest number and the smallest number in the set." Source: Onwubiko page 176.
The following statements are from range:
"If na.rm is FALSE, NA and NaN values in any of the
arguments will cause NA values to be returned, otherwise NA
values are ignored."
"If finite is TRUE, the minimum and maximum of all finite values is
computed, i.e., finite = TRUE includes na.rm = TRUE."
ranges as the difference between the maximum and minimum values in x
as a numeric vector. Unlike the range, ranges can't
take character vectors as arguments, only numeric vectors.
Irucka Embry
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.
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.
Chinyere Onwubiko, An Introduction to Engineering, Mission, Kansas: Schroff Development Corporation, 1997, page 176.
sgm for geometric mean, shm for harmonic mean, cv for
coefficient of variation (CV), rms for root-mean-square (RMS), relerror
for relative error, and approxerror for approximate error.
# Example 1 install.load::load_package("iemisc", "rando") set_n(100) # makes the example reproducible x <- r_norm(.seed = 943) ranges(x) install.load::load_package("iemisc", "rando") set_n(100) # makes the example reproducible (r.x <- ranges(r_norm(.seed = 100))); r.x # See Source 1 and Source 2 # Example 2 (from the base range function) library(iemisc) xi <- c(NA, 1:3, -1:1/0); xi try(ranges(xi)) try(ranges(xi, na.rm = TRUE)) try(ranges(xi, finite = TRUE))# Example 1 install.load::load_package("iemisc", "rando") set_n(100) # makes the example reproducible x <- r_norm(.seed = 943) ranges(x) install.load::load_package("iemisc", "rando") set_n(100) # makes the example reproducible (r.x <- ranges(r_norm(.seed = 100))); r.x # See Source 1 and Source 2 # Example 2 (from the base range function) library(iemisc) xi <- c(NA, 1:3, -1:1/0); xi try(ranges(xi)) try(ranges(xi, na.rm = TRUE)) try(ranges(xi, finite = TRUE))
Rate for an Area to Change (Gain or Loss)
rate_area_change( area_start, area_end = NULL, time, output = c("units", "no units"), area_unit = c("acre", "square feet", "square mile", "hectare", "square kilometer", "square yard", "square meter", "square inch", "square millimeter", "square centimeter"), time_unit = c("seconds", "minutes", "hours", "days", "weeks", "months", "years") )rate_area_change( area_start, area_end = NULL, time, output = c("units", "no units"), area_unit = c("acre", "square feet", "square mile", "hectare", "square kilometer", "square yard", "square meter", "square inch", "square millimeter", "square centimeter"), time_unit = c("seconds", "minutes", "hours", "days", "weeks", "months", "years") )
area_start |
numeric vector that contains the value of the starting area |
area_end |
numeric vector that contains the value of the ending area |
output |
character vector that contains the output type ("basic" or
"tables"), either it will be a |
area_unit |
character vector containing the units for area (area_start and area_end should have the same units). The default area_unit = "acre". The other possible units are "square feet", "square mile", "hectare", "square kilometer", "square yard", "square meter", "square inch", "square millimeter", or "square centimeter". "seconds"). The other possible units are "minutes", "hours", "days", "weeks", "months", or "years". |
rate |
numeric vector that rate of change for the given area |
the numeric vector Q, which is the "peak flow" in cubic feet per second (cfs or ft^3/s)
Irucka Embry
SCFM (South Cumberland Farmers Market). Newsletter: "Tennessee ranks third in the nation for agricultural land loss... The Farmland Preservation Bill could help. Lots to look out for... new veggies, updates from SeTNYF, and a little bit on The Farmland Preservation Bill and how to support it." By Liz Calabria and Rooted Here, Feb 16, 2025, https://scfm.substack.com/p/updates-from-setnyf-and-new-farm.
United States Department of Agriculture (USDA) National Agricultural Statistics Service (NASS). 2023 State Agriculture Overview for Tennessee, https://web.archive.org/web/20240331222922/https://www.nass.usda.gov/Quick_Stats/Ag_Overview/stateOverview.php?state=TENNESSEE.
United States Department of Agriculture (USDA) National Agricultural Statistics Service (NASS). 2024 State Agriculture Overview for Tennessee, https://web.archive.org/web/20250421004820/https://www.nass.usda.gov/Quick_Stats/Ag_Overview/stateOverview.php?state=Tennessee.
# Example 1 # Given # Between 1997 and 2017, "1.1 million acres" of Tennessee farmland were lost # (Reference 1) # Question # What was the farmland loss rate in acres per hour in that 10 year period? # Solve the problem install.load::load_package("iemisc", "units") time_yr <- set_units(2017 - 1997, year) # years time_hr <- time_yr units(time_hr) <- make_units(hr) # hours area_start <- 1.1e6 # 1 million acres area_unit <- "acre" time_unit <- "hours" output <- "units" rate_area_change(area_start = area_start, time = time_hr, output = output, area_unit = area_unit, time_unit = time_unit) # Example 2 install.load::load_package("iemisc", "units") time_yr <- set_units(2023 - 2017, year) # years time_hr <- time_yr units(time_hr) <- make_units(hr) # hours area_start <- "10,700,000" # (References 2 and 3) area_end <- 0 area_unit <- "acre" time_unit <- "hours" output <- "units" rate_area_change(area_start = area_start, time = time_hr, output = output, area_unit = area_unit, time_unit = time_unit)# Example 1 # Given # Between 1997 and 2017, "1.1 million acres" of Tennessee farmland were lost # (Reference 1) # Question # What was the farmland loss rate in acres per hour in that 10 year period? # Solve the problem install.load::load_package("iemisc", "units") time_yr <- set_units(2017 - 1997, year) # years time_hr <- time_yr units(time_hr) <- make_units(hr) # hours area_start <- 1.1e6 # 1 million acres area_unit <- "acre" time_unit <- "hours" output <- "units" rate_area_change(area_start = area_start, time = time_hr, output = output, area_unit = area_unit, time_unit = time_unit) # Example 2 install.load::load_package("iemisc", "units") time_yr <- set_units(2023 - 2017, year) # years time_hr <- time_yr units(time_hr) <- make_units(hr) # hours area_start <- "10,700,000" # (References 2 and 3) area_end <- 0 area_unit <- "acre" time_unit <- "hours" output <- "units" rate_area_change(area_start = area_start, time = time_hr, output = output, area_unit = area_unit, time_unit = time_unit)
Computes the design peak runoff rate (Q) using the modified rational method equation.
rational_formula( C_F, C, i, A, area_units = c("acre", "square feet", "square mile", "hectare", "square kilometer") )rational_formula( C_F, C, i, A, area_units = c("acre", "square feet", "square mile", "hectare", "square kilometer") )
C_F |
numeric vector that contains the "runoff coefficient adjustment factor to account for reduction of infiltration and other losses during high intensity storms" [Input a number between 2 and 10; 25; 50; or 100] |
C |
numeric vector that contains the dimensionless "runoff coefficient to reflect the ratio of rainfall to surface runoff" |
i |
numeric vector that contains the "rainfall intensity in inches per hour (in/hr)" |
A |
numeric vector that contains the drainage area in one of the area_units values. |
area_units |
character vector containing the units for area (default = "acre"). The other possible units are "square feet", "square mile", "hectare", or "square kilometer". |
the numeric vector Q, which is the "peak flow" in cubic feet per second (cfs or ft^3/s)
Please note: Refer to the limitations of the Modified Rational Method equation for your particular jurisdiction. Notes are only included below for Oklahoma and Oregon, respectively.
for Oklahoma "The Rational Method, first introduced in 1889, is recommended for estimating the design storm peak runoff for areas up to 640 acres. The Rational Method was modified in the 1980's to include a runoff coefficient correction tied to the flood frequency. This Modified Rational Method is used by ODOT.
Some precautions should be considered when applying the Rational method: –The first step in applying the Rational method is to obtain a good topographic map and define the boundaries of the drainage area in question. A field inspection of the area should also be made to determine if the natural drainage divides have been altered. –In determining surface characteristics for the drainage area, consider any future changes in land use that might occur during the service life of the proposed facility that could result in an inadequate drainage system. Also, the effects of upstream detention facilities may be considered. –Restrictions to the natural flow (e.g., highway crossings and dams that exist in the drainage area) should be investigated to determine how they might affect the design flows. –The charts, graphs and tables included in this Section are not intended to replace reasonable and prudent engineering judgment that should permeate each step in the design process." [Oklahoma Department of Transportation Reference]
for Oregon: "Limitations and assumptions in the Rational Method are as follows: –The drainage area should not be larger than 200 acres. –The peak flow is assumed to occur when the entire watershed is contributing runoff. –The rainfall intensity is assumed to be uniform over a time duration equal to or greater than the time of concentration, Tc. –The peak flow recurrence interval is assumed to be equal to the rainfall intensity recurrence interval. In other words, the 10-year rainfall intensity is assumed to produce the 10-year flood." [Oregon Department of Transportation Reference]
The value of 1.008 is used for the unit conversion factor for English units. [Tennessee Design reference]
Irucka Embry
Design Principles for Erosion Prevention & Sediment Control for Construction Sites Level II EPSC Workshop, Fall 2017. Sponsored by The University of Tennessee Biosystems Engineering & Environmental Sciences Tennessee Water Resources Research Center, Tennessee Department of Environment and Conservation Division of Water Resources, and Tennessee Department of Transportation.
Oklahoma Department of Transportation (ODOT) Roadway Drainage Manual Chapter 7 Hydrology, November 2014, page 7.6-1, https://oklahoma.gov/content/dam/ok/en/odot/documents/chapter-7-hydrology.pdf.
Oregon Department of Transportation (ODOT) Geo-Environmental, ODOT Hydraulics Manual Appendix F – Rational Method, April 2014, page 7-F-1, https://web.archive.org/web/20221202194502/https://www.oregon.gov/odot/GeoEnvironmental/Docs_Hydraulics_Manual/Hydraulics-07-F.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
U.S. Department of Agriculture (USDA) Natural Resources Conservation Service (NRCS), Hydrology Training Series Module 206 D - Peak Discharge (Other Methods) Study Guide, page 18 (of the PDF document) and pages 26-27 (of the PDF document), https://web.archive.org/web/20211018222532/https://www.nrcs.usda.gov/Internet/FSE_DOCUMENTS/stelprdb1083019.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
# Example 1 from NRCS Reference # Given # Urban setting with a drainage area of 12 acres # 6 acres = single family area # 3 acres = park # 3 acres = streets (concrete) # Soil = clay loam # Tc = 20 min (time of concentration) # Find the instantaneous peak discharge for a 25-yr frequency flood at a # road crossing in an urban/rural area located in the Kansas City, Missouri # area. library(iemisc) area1 <- c(6, 3, 3) C1 <- c(mean(c(0.30, 0.50)), 0.15, 0.90) C1_w <- weighted_C(C = C1, area = area1) i1 <- 5.1 # in/hr rational_formula(C_F = 25, C = C1_w, i = i1, A = sum(area1), area_units = "acre") # Example 2 from NRCS Reference # Given # Urban setting with a drainage area of 18 acres # 1 ac = playground # 10 ac = single family area # 2 ac = streets (asphaltic) # 5 ac = pasture (hilly) # Soil = heavy clay # Tc = 20 min # Find the instantaneous 100-yr frequency peak discharge for design of a # channel in a developing subdivision located in an area near Asheville, # North Carolina. library(iemisc) area2 <- c(1, 10, 2, 5) C2 <- c(0.35, 0.50, 0.90, 0.60) C2_w <- weighted_C(C = C2, area = area2) i2 <- 5.5 # in/hr rational_formula(C_F = 100, C = C2_w, i = i2, A = sum(area2), area_units = "acre")# Example 1 from NRCS Reference # Given # Urban setting with a drainage area of 12 acres # 6 acres = single family area # 3 acres = park # 3 acres = streets (concrete) # Soil = clay loam # Tc = 20 min (time of concentration) # Find the instantaneous peak discharge for a 25-yr frequency flood at a # road crossing in an urban/rural area located in the Kansas City, Missouri # area. library(iemisc) area1 <- c(6, 3, 3) C1 <- c(mean(c(0.30, 0.50)), 0.15, 0.90) C1_w <- weighted_C(C = C1, area = area1) i1 <- 5.1 # in/hr rational_formula(C_F = 25, C = C1_w, i = i1, A = sum(area1), area_units = "acre") # Example 2 from NRCS Reference # Given # Urban setting with a drainage area of 18 acres # 1 ac = playground # 10 ac = single family area # 2 ac = streets (asphaltic) # 5 ac = pasture (hilly) # Soil = heavy clay # Tc = 20 min # Find the instantaneous 100-yr frequency peak discharge for design of a # channel in a developing subdivision located in an area near Asheville, # North Carolina. library(iemisc) area2 <- c(1, 10, 2, 5) C2 <- c(0.35, 0.50, 0.90, 0.60) C2_w <- weighted_C(C = C2, area = area2) i2 <- 5.5 # in/hr rational_formula(C_F = 100, C = C2_w, i = i2, A = sum(area2), area_units = "acre")
Various Methods of Calculating the Reynolds number
Re1(D, V, rho, mu, gc = NULL, units = c("SI", "Eng", "slug"))Re1(D, V, rho, mu, gc = NULL, units = c("SI", "Eng", "slug"))
D |
numeric vector that contains the hydraulic diameters '(four times the area in flow divided by the wetted surface) is a characteristic length' (m or ft) [Reference: Lindeburg Manual] |
V |
numeric vector that contains the average fluid velocity (m/s or ft/s) [Reference: Lindeburg Manual] |
rho |
numeric vector that contains the fluid density (kg/m^3 or lbm/ft^3) [Reference: Lindeburg Manual] |
mu |
numeric vector that contains the absolute or dynamic viscosity of the fluid (Pa-s or lbf-sec/ft^2) [Reference: Lindeburg Manual] |
gc |
numeric vector that contains the gravitational constant (32.2 lbm-ft/lbf-sec^2) [Reference: Lindeburg Manual] |
units |
character vector that contains the system of units [options are
|
The Reynolds number, named after Osborne Reynolds, is a dimensionless number that is used to determine the type of fluid flow (laminar, transition, or turbulent). [References: Lindeburg Manual and Subramanian]
Re1 - uses the absolute or dynamic viscosity (\mu) Re2 and Re4 - use kinematic viscosity (\nu) Re3 - uses the 'mass flow rate per unit area' (G) [Reference: Lindeburg Manual]
The Reynolds number equation can be expressed in the following ways [Reference: Lindeburg Manual]:
the Reynolds number (dimensionless)
the hydraulic diameters (m)
average velocity of the fluid (m/s)
density of the fluid at a certain temperature (kg/m^3)
absolute or dynamic viscosity of the fluid at a certain temperature (Pa-s)
the Reynolds number (dimensionless)
the hydraulic diameters (ft)
average velocity of the fluid (ft/sec)
density of the fluid at a certain temperature (lbm/ft^3)
absolute or dynamic viscosity of the fluid at a certain temperature (lbf-sec/ft^2)
gravitational constant (32.2 lbm-ft/lbf-sec^2) used for dimensional analysis so that the Reynolds number will be dimensionless with US Customary units
the Reynolds number (dimensionless)
the hydraulic diameters (m)
'mass flow rate per unit area' (kg/m^2-s)
absolute or dynamic viscosity of the fluid at a certain temperature (Pa-s)
the Reynolds number (dimensionless)
the hydraulic diameters (ft)
'mass flow rate per unit area' (lbm/ft^2-sec)
absolute or dynamic viscosity of the fluid at a certain temperature (lbf-sec/ft^2)
gravitational constant (32.2 lbm-ft/lbf-sec^2) used for dimensional analysis so that the Reynolds number will be dimensionless with US Customary units
where
'mass flow rate per unit area' (kg/m^2-s)
density of the fluid at a certain temperature (kg/m^3)
average velocity of the fluid (m/s)
the Reynolds number (dimensionless)
the hydraulic diameters (m)
average velocity of the fluid (m/s)
kinematic viscosity of the fluid at a certain temperature (m^2/s)
the Reynolds number (dimensionless)
the hydraulic diameters (ft)
average velocity of the fluid (ft/sec)
absolute or dynamic viscosity of the fluid at a certain temperature (lbf-sec/ft^2)
gravitational constant (32.2 lbm-ft/lbf-sec^2) used for dimensional analysis so that the Reynolds number will be dimensionless with US Customary units
where
kinematic viscosity of the fluid at a certain temperature (m^2/s)
absolute or dynamic viscosity of the fluid at a certain temperature (Pa-s)
density of the fluid at a certain temperature (kg/m^3)
where
kinematic viscosity of the fluid at a certain temperature (ft^2/sec)
absolute or dynamic viscosity of the fluid at a certain temperature (lbf-sec/ft^2)
gravitational constant (32.2 lbm-ft/lbf-sec^2) used for dimensional analysis so that the kinematic viscosity units will work in US Customary units
density of the fluid at a certain temperature (lbm/ft^3)
the Reynolds number as a list for Re1
Please Note: The conventional wisdom that a Reynolds number less than 2100 is laminar flow, between 2100 and 4000 is transitional or critical flow, and greater than 4000 is turbulent flow is not accurate. 'Reynolds himself observed that turbulence was triggered by inlet disturbances to the pipe and the laminar state could be maintained to Re \u2248 12,000 if he took great care in minimizing external disturbances to the flow. By careful design of pipe entrances Ekman (1910) has maintained laminar pipe flow up to a Reynolds number of 40,000 and Pfenniger (1961) up to 100,000 by minimising ambient disturbances.' [References: Lindeburg Manual and Trinh]
'Numerous experiments have shown that the flow in a pipe changes from laminar to turbulent in the range of R between the critical value of 2,000 and a value that may be as high as 50,000.* In these experiments the diameters of the pipe was taken as the characteristic length in defining the Reynolds number. When the hydraulic radius is taken as the characteristic length, the corresponding range is from 500 to 12,500,* since the diameters of a pipe is four times its hydraulic radius. * = It should be noted that there is actually no definite upper limit.' [Reference: Chow]
Note: Units must be consistent
Irucka Embry
Ven Te Chow, Ph.D., Open-Channel Hydraulics, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 7-8.
Michael R. Lindeburg, PE, Civil Engineering Reference Manual for the PE Exam, Twelfth Edition, Belmont, California: Professional Publications, Inc., 2011, pages 17-1, 17-5, 17-8 - 17-9.
The NIST Reference on Constants, Units, and Uncertainty, Fundamental Constants Data Center of the NIST Physical Measurement Laboratory, "standard acceleration of gravity g_n", https://web.archive.org/web/20230427133623/https://physics.nist.gov/cgi-bin/cuu/Value?gn. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
R. Shankar Subramanian, "Pipe Flow Calculations", page 9, Clarkson University Department of Chemical and Biomolecular Engineering, https://lin-web.clarkson.edu/projects/subramanian/ch330/notes/Pipe%20Flow%20Calculations.pdf.
R. Shankar Subramanian, "Reynolds Number", page 1, Clarkson University Department of Chemical and Biomolecular Engineering, https://lin-web.clarkson.edu/projects/subramanian/ch330/notes/Reynolds%20Number.pdf.
Khanh Tuoc Trinh, "On the Critical Reynolds Number for Transition From Laminar to Turbulent Flow", page 2, https://arxiv.org/abs/1007.0810.
Wikimedia Foundation, Inc. Wikipedia, 15 May 2019, "Conversion of units", https://en.wikipedia.org/wiki/Conversion_of_units.
f1, f2, f3, f4, f5, f6, f7, and f8
for the Darcy friction factor (f) for pipes
# from Lindeburg Reference page 17-8 # D = 0.3355 ft # V = 7.56 ft/sec # from the Chow reference, water at 68 F (20 C) has the following properties library(iemisc) # mu (dynamic viscosity) = 2.09 * 10 ^ -5 slug/ft-sec # rho (density) = 1.937 slug/ft^3 # v (kinematic viscosity) = mu / rho = 1.08 * 10 ^ -5 Re1(D = 0.3355, V = 7.56, rho = 1.937, mu = 2.09 * 10 ^ -5, units = "slug")# from Lindeburg Reference page 17-8 # D = 0.3355 ft # V = 7.56 ft/sec # from the Chow reference, water at 68 F (20 C) has the following properties library(iemisc) # mu (dynamic viscosity) = 2.09 * 10 ^ -5 slug/ft-sec # rho (density) = 1.937 slug/ft^3 # v (kinematic viscosity) = mu / rho = 1.08 * 10 ^ -5 Re1(D = 0.3355, V = 7.56, rho = 1.937, mu = 2.09 * 10 ^ -5, units = "slug")
Calculating the Reynolds Number 2
Re2(D, V, nu)Re2(D, V, nu)
D |
numeric vector that contains the hydraulic diameters "(four times the area in flow divided by the wetted surface) is a characteristic length" (m or ft) [Reference: Lindeburg Manual] |
V |
numeric vector that contains the average fluid velocity (m/s or ft/s) [Reference: Lindeburg Manual] |
nu |
numeric vector that contains the kinematic viscosity of the fluid (m^2/s or lbf-sec/ft^2) [Reference: Lindeburg Manual] |
the Reynolds number as a numeric vector for Re2
Irucka Embry
Re1 for the additional seealso, description, details, note, and references sections, Re3, Re4
# from Lindeburg Reference page 17-8 # where # D = 0.3355 ft # V = 7.56 ft/sec # nu = 1.41 * 10 ^ -5 ft^2 / sec # and # Re = 1.8 * 10 ^ 5 library(iemisc) Re2(D = 0.3355, V = 7.56, nu = 1.41 * 10 ^ -5) # compare to Re1(D = 0.3355, V = 7.56, rho = 1.937, mu = 2.09 * 10 ^ -5, units = "slug") Re2(D = 0.3355, V = 7.56, nu = 1.08 * 10 ^ -5)# from Lindeburg Reference page 17-8 # where # D = 0.3355 ft # V = 7.56 ft/sec # nu = 1.41 * 10 ^ -5 ft^2 / sec # and # Re = 1.8 * 10 ^ 5 library(iemisc) Re2(D = 0.3355, V = 7.56, nu = 1.41 * 10 ^ -5) # compare to Re1(D = 0.3355, V = 7.56, rho = 1.937, mu = 2.09 * 10 ^ -5, units = "slug") Re2(D = 0.3355, V = 7.56, nu = 1.08 * 10 ^ -5)
Calculating the Reynolds Number 3
Re3(D, G, mu, gc = NULL, units = c("SI", "Eng"))Re3(D, G, mu, gc = NULL, units = c("SI", "Eng"))
D |
numeric vector that contains the hydraulic diameters "(four times the area in flow divided by the wetted surface) is a characteristic length" (m or ft) [Reference: Lindeburg Manual] |
G |
numeric vector that contains the 'mass flow rate per unit area' (kg/m^2-s or lbm/ft^2-sec) [Reference: Lindeburg Manual] |
mu |
numeric vector that contains the absolute or dynamic viscosity of the fluid (Pa-s or lbf-sec/ft^2) [Reference: Lindeburg Manual] |
gc |
numeric vector that contains the gravitational constant (32.2 lbm-ft/lbf-sec^2) [Reference: Lindeburg Manual] |
units |
character vector that contains the system of units [options are
|
the Reynolds number as a numeric vector for Re3
Note: Please see the Calculating the Reynolds number Examples vignette for usage of Re3
Irucka Embry
Re1 for the additional seealso, description, details, note, and references sections, Re2, Re4
Calculating the Reynolds Number 4
Re4(Q, nu, D)Re4(Q, nu, D)
Q |
numeric vector that contains the discharge value of the fluid (m^3/s or ft^3/s) [Reference: Lindeburg Manual] |
nu |
numeric vector that contains the kinematic viscosity of the fluid (m^2/s or lbf-sec/ft^2) [Reference: Lindeburg Manual] |
D |
numeric vector that contains the hydraulic diameters "(four times the area in flow divided by the wetted surface) is a characteristic length" (m or ft) [Reference: Lindeburg Manual] |
the Reynolds number as a numeric vector for Re4
Irucka Embry
Re1 for the additional seealso, description, details, note, and references sections, Re2, Re3
# part of Example 3 from Subramanian Pipe Flow Calculations # Q = 2.23 * 10 ^ - 2 ft^3/s # nu = 2.40 * 10 ^ -5 ft^2/s # D = 9.03 * 10 ^ -2 ft library(iemisc) Re4(Q = 2.23 * 10 ^ -2, nu = 2.40 * 10 ^ -5, D = 9.03 * 10 ^ -2)# part of Example 3 from Subramanian Pipe Flow Calculations # Q = 2.23 * 10 ^ - 2 ft^3/s # nu = 2.40 * 10 ^ -5 ft^2/s # D = 9.03 * 10 ^ -2 ft library(iemisc) Re4(Q = 2.23 * 10 ^ -2, nu = 2.40 * 10 ^ -5, D = 9.03 * 10 ^ -2)
Takes a character vector coercible to a date using anydate or a date time
using anytime; a character vector with numbers; a
numeric vector; or an integer vector & computes the sum to a single digit using
Mod_octave
The vectors may include periods, dashes, parentheses, colons, slashes, and/or spaces. Refer to the examples.
reduce_single_digit(string)reduce_single_digit(string)
string |
character vector coercible to a date using |
a numeric vector with a single digit (integer from 0 - 9)
Irucka Embry
GeeksforGeeks, Last updated on 13 Jun, 2022, "Finding sum of digits of a number until sum becomes single digit", ‘https://www.geeksforgeeks.org/finding-sum-of-digits-of-a-number-until-sum-becomes-single-digit/’.
paste - R - Collapse By Row - Stack Overflow answered by mpalanco on Jul 10, 2015. See ‘https://stackoverflow.com/questions/31280578/r-collapse-by-row’.
Numerology.com, "Number 9 Meaning", ‘https://www.numerology.com/articles/about-numerology/single-digit-number-9-meaning/’.
Numerology.com, "Numerology Numbers 1-9: Exploring the single digit numbers in Numerology", ‘https://www.numerology.com/articles/about-numerology/single-digit-numbers-in-numerology/’.
Wikimedia Foundation, Inc. Wikipedia, 18 November 2022, "Digital root", ‘https://en.wikipedia.org/wiki/Digital_root’.
# Please refer to the iemisc: Sound Frequencies & Nikola Tesla's 3-6-9 Theory # vignette # https://www.ecoccs.com/R-Examples/SoundFrequencies-and-3-6-9.pdf for # additional examples # Examples library(iemisc) reduce_single_digit(pi) reduce_single_digit(37) reduce_single_digit(c(4, 5, 245, 9, 12)) reduce_single_digit(c(-2, -5, -1093, -0.9993)) reduce_single_digit("34 1/2") reduce_single_digit("49 ft 7 5/8 in") reduce_single_digit("56-9 1/2\"") reduce_single_digit(34.5) reduce_single_digit(9) reduce_single_digit(0) reduce_single_digit(94321155) reduce_single_digit(5094322.439344993211394) reduce_single_digit(-438443.349435493) reduce_single_digit("-48373744582.47362287482374") reduce_single_digit("11-09-2022") reduce_single_digit("2001/01/31") reduce_single_digit("24 December 1983 04:37:58.55543333") reduce_single_digit("4 July 1776") reduce_single_digit("19.11.2002") reduce_single_digit("011 (704) 904-0432") reduce_single_digit("011-894-908-0945") reduce_single_digit("908-0945") # data.table example dff <- data.table::data.table(V1 = c(23, 29), V2 = c(1, 40), V3 = c(5, 78), V4 = c(9, 2), V5 = c(17, 34)) sapply(do.call(paste0, dff), reduce_single_digit) # V5 column only of the data.table sapply(dff$V5, reduce_single_digit) # Which of the following dates have a integer sum of 3, 6, or 9? datess <- seq(as.Date("2001/07/17"), as.Date("2001/08/03"), by = "day") datess xt <- sapply(datess, reduce_single_digit) xt datess[which(xt == 3 | xt == 6 | xt == 9)]# Please refer to the iemisc: Sound Frequencies & Nikola Tesla's 3-6-9 Theory # vignette # https://www.ecoccs.com/R-Examples/SoundFrequencies-and-3-6-9.pdf for # additional examples # Examples library(iemisc) reduce_single_digit(pi) reduce_single_digit(37) reduce_single_digit(c(4, 5, 245, 9, 12)) reduce_single_digit(c(-2, -5, -1093, -0.9993)) reduce_single_digit("34 1/2") reduce_single_digit("49 ft 7 5/8 in") reduce_single_digit("56-9 1/2\"") reduce_single_digit(34.5) reduce_single_digit(9) reduce_single_digit(0) reduce_single_digit(94321155) reduce_single_digit(5094322.439344993211394) reduce_single_digit(-438443.349435493) reduce_single_digit("-48373744582.47362287482374") reduce_single_digit("11-09-2022") reduce_single_digit("2001/01/31") reduce_single_digit("24 December 1983 04:37:58.55543333") reduce_single_digit("4 July 1776") reduce_single_digit("19.11.2002") reduce_single_digit("011 (704) 904-0432") reduce_single_digit("011-894-908-0945") reduce_single_digit("908-0945") # data.table example dff <- data.table::data.table(V1 = c(23, 29), V2 = c(1, 40), V3 = c(5, 78), V4 = c(9, 2), V5 = c(17, 34)) sapply(do.call(paste0, dff), reduce_single_digit) # V5 column only of the data.table sapply(dff$V5, reduce_single_digit) # Which of the following dates have a integer sum of 3, 6, or 9? datess <- seq(as.Date("2001/07/17"), as.Date("2001/08/03"), by = "day") datess xt <- sapply(datess, reduce_single_digit) xt datess[which(xt == 3 | xt == 6 | xt == 9)]
This function computes the relative error.
relerror(xt, xa)relerror(xt, xa)
xt |
numeric vector that contains the true value(s) |
xa |
numeric vector that contains the approximate value(s) |
Relative error is expressed as
the "true percent relative error"
the true value
the approximate value
relative error, as a percent (%), as a numeric vector.
Irucka Embry
Steven C. Chapra, Applied Numerical Methods with MATLAB for Engineers and Scientists, Second Edition, Boston, Massachusetts: McGraw-Hill, 2008, pages 82-83.
sgm for geometric mean, shm for harmonic mean, cv for
coefficient of variation (CV), rms for root-mean-square (RMS), approxerror
for approximate error, and ranges for sample range.
library(iemisc) # Example 4.1 from the Reference text (page 83) relerror(1.648721, 1.5) # answer as a percent (\%)library(iemisc) # Example 4.1 from the Reference text (page 83) relerror(1.648721, 1.5) # answer as a percent (\%)
Obtain the remainder after division in a manner compatible with GNU Octave/MATLAB.
Rem(x, n)Rem(x, n)
x, n
|
An R object (array, matrix, vector) |
"Return the remainder of the division x / y." Source: Eaton.
Irucka Embry, Samit Basu (FreeMat)
Samit Basu (2002-2006). FreeMat v4.0, ‘https://freemat.sourceforge.net/help/mathfunctions_rem.html’.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. ‘https://docs.octave.org/octave.pdf’. Page 564.
# Example from GNU Octave library(iemisc) x <- 23.4 y <- 20 Rem(x, y) # Please refer to the iemisc: Examples from GNU Octave Rem, Mod, and # fractdiff Compatible Functions vignette for additional examples# Example from GNU Octave library(iemisc) x <- 23.4 y <- 20 Rem(x, y) # Please refer to the iemisc: Examples from GNU Octave Rem, Mod, and # fractdiff Compatible Functions vignette for additional examples
This function computes the missing length (must have at least 2 sides) and the interior angles (degrees) of a right triangle.
righttri(a = NULL, b = NULL, c = NULL)righttri(a = NULL, b = NULL, c = NULL)
a |
numeric vector that contains the known side a, if known |
b |
numeric vector that contains the known side b, if known |
c |
numeric vector that contains the known side c (hypotenuse), if known |
Side a is the side adjacent to angle B and opposite angle A. Side b
is the side adjacent to angle A and opposite angle B. Side c (hypotenuse)
is opposite the right angle (angle C).
This function makes the following calculations:
the length of the missing side using the Pythagorean theorem,
the area of the right triangle,
the altitude of the right triangle,
the angle associated with the side named a (degrees),
the angle associated with the side named b (degrees), and
the angle associated with the side named c (degrees).
list of known sides a, b, and c & the interior angles
A, B, and C (right angle), in degrees, if and only if the given
sides create a right triangle.
Irucka Embry
r - Better error message for stopifnot? - Stack Overflow answered by Andrie on Dec 1 2011. See https://stackoverflow.com/questions/8343509/better-error-message-for-stopifnot.
r - switch() statement usage - Stack Overflow answered by Tommy on Oct 19 2011 and edited by Tommy on Mar 6 2012. See https://stackoverflow.com/questions/7825501/switch-statement-usage.
Using Switch Statement in R - Stack Overflow answered by Gavin Simpson on Jul 25 2013. See https://stackoverflow.com/questions/17847034/using-switch-statement-in-r.
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.
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.
r - Better error message for stopifnot? - Stack Overflow answered by Andrie on Dec 1 2011. See https://stackoverflow.com/questions/8343509/better-error-message-for-stopifnot.
Masoud Olia, Ph.D., P.E. and Contributing Authors, Barron's FE (Fundamentals of Engineering Exam), 3rd Edition, Hauppauge, New York: Barron's Educational Series, Inc., 2015, pages 44-45.
Wikimedia Foundation, Inc. Wikipedia, 28 December 2015, "Pythagorean theorem", https://en.wikipedia.org/wiki/Pythagorean_theorem.
Wikimedia Foundation, Inc. Wikipedia, 26 November 2015, "Radian", https://en.wikipedia.org/wiki/Radian.
Wikimedia Foundation, Inc. Wikipedia, 9 December 2015, "Right triangle", https://en.wikipedia.org/wiki/Right_triangle.
library(iemisc) righttri(a = 3, b = 4, c = 5) # See Source 4 and Source 5 library(iemisc) try(righttri(0, 2)) # a = 0, b = 2 try(righttri(1, 2)) # a = 1, b = 2 try(righttri(a = 5, c = 10)) try(righttri(a = 3, c = 10))library(iemisc) righttri(a = 3, b = 4, c = 5) # See Source 4 and Source 5 library(iemisc) try(righttri(0, 2)) # a = 0, b = 2 try(righttri(1, 2)) # a = 1, b = 2 try(righttri(a = 5, c = 10)) try(righttri(a = 3, c = 10))
This function computes the sample root-mean-square (RMS).
rms(x, na.rm = FALSE)rms(x, na.rm = FALSE)
x |
numeric vector that contains the sample data points. |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
RMS is expressed as
the sample harmonic mean
the values in a sample
the number of values
sample root-mean-square as a numeric vector. The default choice is that
any NA values will be kept (na.rm = FALSE). This can be changed by
specifying na.rm = TRUE, such as rms(x, na.rm = TRUE).
Irucka Embry
Masoud Olia, Ph.D., P.E. and Contributing Authors, Barron's FE (Fundamentals of Engineering Exam), 3rd Edition, Hauppauge, New York: Barron's Educational Series, Inc., 2015, page 84.
sgm for geometric mean, shm for harmonic mean, cv
for coefficient of variation (CV), relerror for relative error,
approxerror for approximate error, and ranges for sample range.
library(iemisc) samp <- c(0.5, 100, 1000.25, 345, 0.0213, 0, 45, 99, 23, 11, 1, 89, 0, 34, 65, 98, 3) rms(samp)library(iemisc) samp <- c(0.5, 100, 1000.25, 345, 0.0213, 0, 45, 99, 23, 11, 1, 89, 0, 34, 65, 98, 3) rms(samp)
This function solves for the saturation vapor pressure of water using only the temperature of the water in either units of degrees Celsius, degrees Fahrenheit, or Kelvin.
sat_vapor_pressure( Temp, units = c("SI", "Eng", "Absolute"), formula = c("Huang", "Buck", "IAPWS") )sat_vapor_pressure( Temp, units = c("SI", "Eng", "Absolute"), formula = c("Huang", "Buck", "IAPWS") )
Temp |
numeric vector that contains the temperature (degrees Celsius, degrees Fahrenheit, or Kelvin) |
units |
character vector that contains the system of units (options are
|
formula |
character vector that contains the source of the formula used to compute the saturation vapor pressure (options are Huang, Buck, IAPWS) |
The simplified equation is expressed as
for (t > 0 C)
the saturation vapor pressure (Pa or psi)
the water temperature, degrees Celsius
the saturation vapor pressure for water as a numeric vector. The unit
for SI and Absolute is Pascal (Pa), but the unit for Eng
is pounds per square inch (psi). The units are not returned.
Note: Please refer to the references for the formulas (Huang = Reference 1, IAPWS = Reference 2, and Buck = Reference 3)
Note: Please refer to the iemisc: Comparing Saturated Vapor Pressure Formulas to the Reference vignette for the comparisons to the reference saturated vapor pressure
Irucka Embry
Huang, J. (2018). "A Simple Accurate Formula for Calculating Saturation Vapor Pressure of Water and Ice", Journal of Applied Meteorology and Climatology, 57(6), 1265-1272. Retrieved Nov 4, 2021, https://web.archive.org/web/20221024040058/https://journals.ametsoc.org/view/journals/apme/57/6/jamc-d-17-0334.1.xml. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
The International Association for the Properties of Water and Steam. IAPWS SR1-86(1992). "Revised Supplementary Release on Saturation Properties of Ordinary Water Substance", September 1992, https://www.iapws.org/relguide/Supp-sat.pdf
Holger Vömel, National Center for Atmospheric Research Earth Observing Laboratory, "Saturation vapor pressure formulations", https://web.archive.org/web/20170623040102/http://cires1.colorado.edu/~voemel/vp.html. Retrieved thanks to the Internet Archive: Wayback Machine
# Example 1 - Example from the hydraulics package library(iemisc) vps <- hydraulics::svp(T = 10, units = "SI"); vps vps2 <- sat_vapor_pressure(Temp = 10, units = "SI", formula = "Huang"); vps2 # Example 2 - from the Huang Reference library(iemisc) sat_vapor_pressure(Temp = c(0.01, seq(from = 20, to = 100, by = 20)), units = "SI", formula = "Huang") # Example 3 - compare with saturation_pressure_H2O from aiRthermo install.load::load_package("iemisc", "units") Temp <- 40 # create a numeric vector with the units of degrees Celsius T_C <- set_units(Temp, "degree_C") T_C # create a numeric vector to convert from degrees Celsius to Kelvin T_K <- T_C T_K # create a numeric vector with the units of Kelvin units(T_K) <- make_units(K) pre <- aiRthermo::saturation_pressure_H2O(drop_units(T_K)) pre sat_vapor_pressure(Temp = drop_units(T_K), units = "Absolute", formula = "Huang")# Example 1 - Example from the hydraulics package library(iemisc) vps <- hydraulics::svp(T = 10, units = "SI"); vps vps2 <- sat_vapor_pressure(Temp = 10, units = "SI", formula = "Huang"); vps2 # Example 2 - from the Huang Reference library(iemisc) sat_vapor_pressure(Temp = c(0.01, seq(from = 20, to = 100, by = 20)), units = "SI", formula = "Huang") # Example 3 - compare with saturation_pressure_H2O from aiRthermo install.load::load_package("iemisc", "units") Temp <- 40 # create a numeric vector with the units of degrees Celsius T_C <- set_units(Temp, "degree_C") T_C # create a numeric vector to convert from degrees Celsius to Kelvin T_K <- T_C T_K # create a numeric vector with the units of Kelvin units(T_K) <- make_units(K) pre <- aiRthermo::saturation_pressure_H2O(drop_units(T_K)) pre sat_vapor_pressure(Temp = drop_units(T_K), units = "Absolute", formula = "Huang")
This function solves for the saturation vapor pressure of ice using only the temperature of the water in either units of degrees Celsius, degrees Fahrenheit, or Kelvin.
sat_vapor_pressure_ice(Temp, units = c("SI", "Eng", "Absolute"))sat_vapor_pressure_ice(Temp, units = c("SI", "Eng", "Absolute"))
Temp |
numeric vector that contains the temperature (degrees Celsius, degrees Fahrenheit, or Kelvin) |
units |
character vector that contains the system of units [options are
|
The simplified equation is expressed as
for (t <= 0 C)
the saturation vapor pressure (Pa or psi)
the ice temperature, degrees Celsius
the saturation vapor pressure for ice as a numeric vector. The unit
for SI and Absolute is Pascal (Pa), but the unit for Eng
is pounds per square inch (psi). The units are not returned.
Irucka Embry
Huang, J. (2018). "A Simple Accurate Formula for Calculating Saturation Vapor Pressure of Water and Ice", Journal of Applied Meteorology and Climatology, 57(6), 1265-1272. Retrieved Nov 4, 2021, https://web.archive.org/web/20221024040058/https://journals.ametsoc.org/view/journals/apme/57/6/jamc-d-17-0334.1.xml. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN. Used the Internet Archive: Wayback Machine archived version for acceptance into CRAN.
# Example from the Reference library(iemisc) sat_vapor_pressure_ice(Temp = seq(from = -100, to = 0, by = 20), units = "SI")# Example from the Reference library(iemisc) sat_vapor_pressure_ice(Temp = seq(from = -100, to = 0, by = 20), units = "SI")
Calculates the value of secant for each element of x in radians.
sec(x)sec(x)
x |
A numeric or complex vector containing values in radians |
The secant of each element of x in radians.
Irucka Embry
secd if you have a degree angle value
library(iemisc) # Examples sec (seq(-2, 2, by = 1) * pi) sec ((3 * pi) / 4) sec (c((7/3) * pi, (5/2) * pi))library(iemisc) # Examples sec (seq(-2, 2, by = 1) * pi) sec ((3 * pi) / 4) sec (c((7/3) * pi, (5/2) * pi))
Calculates the value of secant for each element of x in degrees in a
manner compatible with GNU Octave/MATLAB.
secd(x)secd(x)
x |
A numeric vector containing values in degrees |
The secant of each element of x in degrees.
David Bateman (GNU Octave secd), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 553.
sec if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave secd secd (seq(0, 80, by = 10)) secd (c(0, 180, 360)) secd (c(90, 270))library(iemisc) # Examples from GNU Octave secd secd (seq(0, 80, by = 10)) secd (c(0, 180, 360)) secd (c(90, 270))
This function "is a short but really useful script that calculates the section properties for an arbitrary shape with holes." Reference: Caprani
secprop( outer_coord, inner_coord, original_plot = c(0, 1), final_plot = c(0, 1) )secprop( outer_coord, inner_coord, original_plot = c(0, 1), final_plot = c(0, 1) )
outer_coord |
numeric matrix that contains the "outer coordinates (x, y)" Reference: Caprani |
inner_coord |
numeric matrix that contains the "coordinates for a void" Reference: Caprani |
original_plot |
integer vector that contains 0, 1 only. 0 represents do not print the original plot and 1 is for printing the original plot. The default value is 0 (no original plot). |
final_plot |
integer vector that contains 0, 1 only. 0 represents do not print the final (transformed) plot and 1 is for printing the final (transformed) plot. The default value is 1 (final plot will be shown). |
SP numeric vector that contains "A (Area), I (Second Moment of Area), yt and yb properties of the section." Reference: Caprani
Note: Please refer to the iemisc: secprop Example (R and GNU Octave) vignette for the examples
Colin Caprani (secprop MATLAB function), Irucka Embry (secprop R function)
loops - r - foreach unable to find object within function - Stack Overflow answered by sumshyftw on Jun 7 2019. See https://stackoverflow.com/questions/56498824/r-foreach-unable-to-find-object-within-function/56499056.
Colin Caprani, "Section Properties Calculator", https://www.colincaprani.com/programming/matlab/.
This function computes the sample geometric mean.
sgm(x, na.rm = FALSE)sgm(x, na.rm = FALSE)
x |
numeric vector that contains the sample data points (any negative values will be ignored). |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
Geometric mean is expressed as
the sample geometric mean
the values in a sample
the number of positive values
"The geometric mean is used in averaging values that represent a rate of change. It is the positive nth root of the product of the n values."
sample geometric mean as a numeric vector. The default choice is
that any NA values will be kept (na.rm = FALSE). This can be
changed by specifying na.rm = TRUE, such as sgm(x, na.rm = TRUE).
Irucka Embry
Nathabandu T. Kottegoda and Renzo Rosso, Statistics, Probability, and Reliability for Civil and Environmental Engineers, New York City, New York: The McGraw-Hill Companies, Inc., 1997, page 13.
mean for arithmetic mean
shm for harmonic mean, cv for coefficient of
variation (CV), relerror for relative error, approxerror for
approximate error, rms for root-mean-square (RMS), and ranges
for sample range.
# Example 1.13 from Kottegoda (page 13) library(iemisc) city_pop <- c(230000, 310000) sgm(city_pop) # Compare the geometric mean to the arithmetic mean mean(city_pop)# Example 1.13 from Kottegoda (page 13) library(iemisc) city_pop <- c(230000, 310000) sgm(city_pop) # Compare the geometric mean to the arithmetic mean mean(city_pop)
This function computes the sample harmonic mean.
shm(x, na.rm = FALSE)shm(x, na.rm = FALSE)
x |
numeric vector that contains the sample data points. |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
Harmonic mean is expressed as
the sample harmonic mean
the values in a sample
the number of values
"The harmonic mean is the reciprocal of the mean of the reciprocals. It is applied in situations where the reciprocal of a variable is averaged."
sample harmonic mean as a numeric vector. The default choice is that
any NA values will be kept (na.rm = FALSE). This can be changed by
specifying na.rm = TRUE, such as shm(x, na.rm = TRUE).
Irucka Embry
Nathabandu T. Kottegoda and Renzo Rosso, Statistics, Probability, and Reliability for Civil and Environmental Engineers, New York City, New York: The McGraw-Hill Companies, Inc., 1997, page 13.
mean for arithmetic mean
sgm for geometric mean, cv for coefficient of
variation (CV), relerror for relative error, approxerror for
approximate error, rms for root-mean-square (RMS), and ranges
for sample range.
# Example 1.12 from Kottegoda (page 13) install.load::load_package("iemisc", "data.table") x <- c(0.20, 0.24, 0.16) # stream velocities in m/s shm(x) # using a matrix of the numeric vector x mat1 <- matrix(data = x, nrow = length(x), ncol = 1, byrow = FALSE, dimnames = list(c(rep("", length(x))), "Velocities")) shm(mat1) # using a data.frame of the numeric vector x df1 <- data.frame(x) shm(df1) # using a data.table of the numeric vector x df2 <- data.table(x) shm(df2)# Example 1.12 from Kottegoda (page 13) install.load::load_package("iemisc", "data.table") x <- c(0.20, 0.24, 0.16) # stream velocities in m/s shm(x) # using a matrix of the numeric vector x mat1 <- matrix(data = x, nrow = length(x), ncol = 1, byrow = FALSE, dimnames = list(c(rep("", length(x))), "Velocities")) shm(mat1) # using a data.frame of the numeric vector x df1 <- data.frame(x) shm(df1) # using a data.table of the numeric vector x df2 <- data.table(x) shm(df2)
Computes the total interest paid at the end of n periods using simple interest
SimpIntCharg(P, n, i)SimpIntCharg(P, n, i)
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as whole number or decimal |
Simple Interest Charged is expressed as
the "principal amount (lent or borrowed)"
the "simple interest"
the "interest rate per interest period"
the "number of interest periods"
SimpIntCharg numeric vector that contains the simple interest amount paid at the end of n periods rounded to 2 decimal places
Irucka Embry
Chinyere Onwubiko, An Introduction to Engineering, Mission, Kansas: Schroff Development Corporation, 1997, pages 205-206.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 116.
library(iemisc) # Example for equation 4-1 from the Sullivan Reference text (page 116) # Modified example to provide the simple interest amount paid only SimpIntCharg(P = 1000, n = 3, i = 10) # the interest rate is 10%library(iemisc) # Example for equation 4-1 from the Sullivan Reference text (page 116) # Modified example to provide the simple interest amount paid only SimpIntCharg(P = 1000, n = 3, i = 10) # the interest rate is 10%
Computes the total amount paid at the end of n periods using simple interest
SimpIntPaid(P, n, i)SimpIntPaid(P, n, i)
P |
numeric vector that contains the present value(s) |
n |
numeric vector that contains the period value(s) |
i |
numeric vector that contains the interest rate(s) as whole number or decimal |
Simple Interest is expressed as
or
the "principal amount (lent or borrowed)"
the "total amount paid back"
the "simple interest"
the "interest rate per interest period"
the "number of interest periods"
SimpIntPaid numeric vector that contains the total amount paid at the end of n periods rounded to 2 decimal places
Irucka Embry
Chinyere Onwubiko, An Introduction to Engineering, Mission, Kansas: Schroff Development Corporation, 1997, pages 205-206.
William G. Sullivan, Elin M. Wicks, and C. Patrick Koelling, Engineering Economy, Fourteenth Edition, Upper Saddle River, New Jersey: Pearson/Prentice Hall, 2009, page 116.
library(iemisc) # Example for equation 4-1 from the Sullivan Reference text (page 116) SimpIntPaid(1000, 3, 10) # the interest rate is 10%library(iemisc) # Example for equation 4-1 from the Sullivan Reference text (page 116) SimpIntPaid(1000, 3, 10) # the interest rate is 10%
Calculates the value of sine for each element of x in degrees in a
manner compatible with GNU Octave/MATLAB. Zero is returned for any "elements
where x / 180 is an integer." Reference: Eaton.
sind(x)sind(x)
x |
A numeric vector containing values in degrees |
The sine of each element of x in degrees. Zero for any
"elements where x / 180 is an integer."
David Bateman (GNU Octave sind), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 553.
sin if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave sind sind(seq(10, 90, by = 10)) sind(c(0, 180, 360)) sind(c(90, 270))library(iemisc) # Examples from GNU Octave sind sind(seq(10, 90, by = 10)) sind(c(0, 180, 360)) sind(c(90, 270))
Provides the dimensions of R objects in a manner compatible with
GNU Octave/MATLAB. This function is the same as size, except this
size can find the size of character vectors too. Some documentation from
size.
size(x, k)size(x, k)
x |
An R object (array, vector, or matrix) |
k |
integer specifying a particular dimension |
"Return the number of rows and columns of the object x as a numeric
vector. If given a second argument, size will return the size of the
corresponding dimension." Source: Eaton.
Hans Werner Borchers (pracma size), Irucka Embry
pracma size function definition - R package pracma created and maintained by Hans Werner Borchers. See size.
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Pages 47-48.
# Example from GNU Octave ndims function reference size(matlab::ones(4, 1, 2, 1))# Example from GNU Octave ndims function reference size(matlab::ones(4, 1, 2, 1))
This function sorts each row in a tabular object by ascending or descending order of the numeric value in each column. The rearranging of the column names does not matter in this case. Only keeping the existing row order matters here
sort_row_by_column(data, order = c("ascending", "descending"))sort_row_by_column(data, order = c("ascending", "descending"))
roof_table |
data.frame/data.table/tibble, list, or matrix containing the length in column 1 and the width in column 2 for the roof(s). |
rainfall_depth_units |
character vector containing the units for the rainfall depth (default = "feet"). The other possible units are "inch", "centimeter", or "meter". |
a data.table with the following columns:
Driveway Drainage Area, One-Quarter of Roof Area, Depth of Rain, Design
Storm Volume, Rain Garden Depth, Rain Garden Initial Size, Rain Garden
Initial Dimensions, Total Drainage Area, New Design Storm Volume, Rain
Garden Final Size, Rain Garden Final Dimensions
Irucka Embry, jared_mamrot
Stack Overflow, "sorting - R - Sort individual rows of a data.table by ascending order of the value in each column" Answered by jared_mamrot on 23 March 2026, ‘https://stackoverflow.com/questions/79913030/r-sort-individual-rows-of-a-data-table-by-ascending-order-of-the-value-in-each’.
# Examples using data.table, data.frame, matrix, and list library(iemisc) # data.table data <- structure(list(V1 = c(20, 2, 7, 20, 48, 12), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), row.names = c(NA, -6L), class = c("data.table", "data.frame")) data <- data.table::setDT(data) sort_row_by_column(data, order = "ascending") library(iemisc) data(world.cities, package = "maps") data(us.cities, package = "maps") # data.frame data1 <- structure(list(V1 = letters[c(20, 2, 7, 20, 26, 12)], V2 = world.cities[c(1, 48, 23, 56, 28, 11)], V3 = us.cities[c(54, 20, 4, 51, 55, 30)], row.names = c(NA, -3L), class = c("data.frame")) sort_row_by_column(data1, order = "descending") library(iemisc) # matrix data2 <- structure(c(20, 2, 7, 20, 48, 12, 1, 48, 23, 56, 28, 11, 54, 20, 4, 51, 55, 30, 5, 28, 6, 6, 52, 42, 55, 6, 55, 22, 38, 10, 33, 3, 40, 3, 15, 33), dim = c(6L, 6L), dimnames = list(NULL, c("V1", "V2", "V3", "V4", "V5", "V6"))) sort_row_by_column(data2, order = "ascending") # tibble data3 <- structure(list(V1 = c(20, 2, 7, 20, 48, 12), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L)) sort_row_by_column(data3, order = "descending") # list data4 <- structure(list(V1 = c(20.01, 2.2, 7.76, 20.00003, 48.65, 12.342), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), row.names = c(NA, -6L), class = c("data.frame")) data4 <- data.table::setDT(data4) # split on the row numbers data_split <- split(data4, 1:nrow(data4)) sort_row_by_column(data_split, order = "descending") # data.frame data5 <- structure(list(V1 = c(220, 2, 7, 20, 48, 12), V2 = c(1, 48, 263, 56, 28, 11), V3 = c(54, 20, 44, 51, 55, 30), V4 = c(5, 28, 6, 63, 52, 42), V5 = c(55, 67, 505, 22, 38, 210), V6 = c(331, 3, 40, 37, 15, 33)), row.names = c(NA, -6L), class = c("data.frame")) #' sort_row_by_column(data5, order = "ascending") # data.table data1 <- structure(list(V1 = c(20, 2, 7, 20, 48, 12), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), row.names = c(NA, -6L), class = c("data.table", "data.frame")) #' data1 <- data.table::setDT(data1) #' sort_row_by_column(data1, order = "ascending")# Examples using data.table, data.frame, matrix, and list library(iemisc) # data.table data <- structure(list(V1 = c(20, 2, 7, 20, 48, 12), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), row.names = c(NA, -6L), class = c("data.table", "data.frame")) data <- data.table::setDT(data) sort_row_by_column(data, order = "ascending") library(iemisc) data(world.cities, package = "maps") data(us.cities, package = "maps") # data.frame data1 <- structure(list(V1 = letters[c(20, 2, 7, 20, 26, 12)], V2 = world.cities[c(1, 48, 23, 56, 28, 11)], V3 = us.cities[c(54, 20, 4, 51, 55, 30)], row.names = c(NA, -3L), class = c("data.frame")) sort_row_by_column(data1, order = "descending") library(iemisc) # matrix data2 <- structure(c(20, 2, 7, 20, 48, 12, 1, 48, 23, 56, 28, 11, 54, 20, 4, 51, 55, 30, 5, 28, 6, 6, 52, 42, 55, 6, 55, 22, 38, 10, 33, 3, 40, 3, 15, 33), dim = c(6L, 6L), dimnames = list(NULL, c("V1", "V2", "V3", "V4", "V5", "V6"))) sort_row_by_column(data2, order = "ascending") # tibble data3 <- structure(list(V1 = c(20, 2, 7, 20, 48, 12), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L)) sort_row_by_column(data3, order = "descending") # list data4 <- structure(list(V1 = c(20.01, 2.2, 7.76, 20.00003, 48.65, 12.342), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), row.names = c(NA, -6L), class = c("data.frame")) data4 <- data.table::setDT(data4) # split on the row numbers data_split <- split(data4, 1:nrow(data4)) sort_row_by_column(data_split, order = "descending") # data.frame data5 <- structure(list(V1 = c(220, 2, 7, 20, 48, 12), V2 = c(1, 48, 263, 56, 28, 11), V3 = c(54, 20, 44, 51, 55, 30), V4 = c(5, 28, 6, 63, 52, 42), V5 = c(55, 67, 505, 22, 38, 210), V6 = c(331, 3, 40, 37, 15, 33)), row.names = c(NA, -6L), class = c("data.frame")) #' sort_row_by_column(data5, order = "ascending") # data.table data1 <- structure(list(V1 = c(20, 2, 7, 20, 48, 12), V2 = c(1, 48, 23, 56, 28, 11), V3 = c(54, 20, 4, 51, 55, 30), V4 = c(5, 28, 6, 6, 52, 42), V5 = c(55, 6, 55, 22, 38, 10), V6 = c(33, 3, 40, 3, 15, 33)), row.names = c(NA, -6L), class = c("data.table", "data.frame")) #' data1 <- data.table::setDT(data1) #' sort_row_by_column(data1, order = "ascending")
This function solves for the specific volume of a substance using only the substance's density and the density of water.
sp_gravity( rho_w, rho_s, units = c("SI", "Eng"), Eng_units = c("slug/ft^3", "lbm/ft^3") )sp_gravity( rho_w, rho_s, units = c("SI", "Eng"), Eng_units = c("slug/ft^3", "lbm/ft^3") )
rho_w |
numeric vector that contains the density of water |
rho_s |
numeric vector that contains the density of the substance |
units |
character vector that contains the system of units [options are
|
Eng_units |
character vector that contains the unit for the density of water [options are slug/ft^3 or lbm/ft^3] |
The equation is expressed as
specific volume (dimensionless)
unit weight or specific weight of water (N/m^3 or lbf/ft^3)
substance density (mass divided by volume) [kg/m^3, slug/ft^3", or lbm/ft^3]
water density (mass divided by volume) [kg/m^3, slug/ft^3", or lbm/ft^3]
the specific volume as a numeric vector
Irucka Embry
Material Properties, 27 March 2022, "Sand – Density – Heat Capacity – Thermal Conductivity", https://material-properties.org/sand-density-heat-capacity-thermal-conductivity/
WikiEngineer, 27 March 2022, "Water Properties & Definitions", https://web.archive.org/web/20210412034245/http://www.wikiengineer.com/Water-Resources/PropertiesAndDefinitions. Retrieved thanks to the Internet Archive: Wayback Machine
# Examples install.load::load_package("iemisc", "units") # The density of sand is 1500 kg/m^3 -- Reference 1 rho_sand <- set_units(1500, "kg/m^3") # convert this density to slug/ft^3 rho_sand_slug <- rho_sand # create a numeric vector with the units of slug/ft^3 units(rho_sand_slug) <- make_units(slug/ft^3) # convert this density to lbm/ft^3 rho_sand_lbm <- rho_sand # create a numeric vector with the units of lb/ft^3 units(rho_sand_lbm) <- make_units(lb/ft^3) rho1 <- density_water(Temp = 68, units = "Eng", Eng_units = "slug/ft^3") sp_gravity(rho_w = rho1, rho_s = rho_sand_slug, units = "Eng", Eng_units = "slug/ft^3") rho2 <- density_water(Temp = 68, units = "Eng", Eng_units = "lbm/ft^3") sp_gravity(rho_w = rho2, rho_s = rho_sand_lbm, units = "Eng", Eng_units = "lbm/ft^3") rho3 <- density_water(Temp = 20, units = "SI") sp_gravity(rho_w = rho3, rho_s = rho_sand, units = "SI")# Examples install.load::load_package("iemisc", "units") # The density of sand is 1500 kg/m^3 -- Reference 1 rho_sand <- set_units(1500, "kg/m^3") # convert this density to slug/ft^3 rho_sand_slug <- rho_sand # create a numeric vector with the units of slug/ft^3 units(rho_sand_slug) <- make_units(slug/ft^3) # convert this density to lbm/ft^3 rho_sand_lbm <- rho_sand # create a numeric vector with the units of lb/ft^3 units(rho_sand_lbm) <- make_units(lb/ft^3) rho1 <- density_water(Temp = 68, units = "Eng", Eng_units = "slug/ft^3") sp_gravity(rho_w = rho1, rho_s = rho_sand_slug, units = "Eng", Eng_units = "slug/ft^3") rho2 <- density_water(Temp = 68, units = "Eng", Eng_units = "lbm/ft^3") sp_gravity(rho_w = rho2, rho_s = rho_sand_lbm, units = "Eng", Eng_units = "lbm/ft^3") rho3 <- density_water(Temp = 20, units = "SI") sp_gravity(rho_w = rho3, rho_s = rho_sand, units = "SI")
This function solves for the specific volume of a substance using only the substance's density
sp_volume(rho)sp_volume(rho)
rho |
numeric vector that contains the density |
The equation is expressed as
substance density (mass divided by volume) [kg/m^3, slug/ft^3", or lbm/ft^3]
the specific volume as a numeric vector
Irucka Embry
WikiEngineer, 27 March 2022, "Water Properties & Definitions", https://web.archive.org/web/20210412034245/http://www.wikiengineer.com/Water-Resources/PropertiesAndDefinitions. Retrieved thanks to the Internet Archive: Wayback Machine
# Examples library(iemisc) rho1 <- density_water(Temp = 68, units = "Eng", Eng_units = "slug/ft^3") sp_volume(rho = rho1) # slug/ft^3 rho2 <- density_water(Temp = 68, units = "Eng", Eng_units = "lbm/ft^3") sp_volume(rho = rho2) # lbm/ft^3 rho3 <- density_water(Temp = 20, units = "SI") sp_volume(rho = rho3) # kg / m^3# Examples library(iemisc) rho1 <- density_water(Temp = 68, units = "Eng", Eng_units = "slug/ft^3") sp_volume(rho = rho1) # slug/ft^3 rho2 <- density_water(Temp = 68, units = "Eng", Eng_units = "lbm/ft^3") sp_volume(rho = rho2) # lbm/ft^3 rho3 <- density_water(Temp = 20, units = "SI") sp_volume(rho = rho3) # kg / m^3
This function takes a character string in the form of Last Name (Surname), First Name or Second String, First String and transposes that string to First Name Last Name (Surname) or First String Second String while removing the comma.
splitcomma(string)splitcomma(string)
string |
character vector that contains a phrase separated by a comma or not. If not, there is no change. |
the character vector in the form of First Name Last Name
Irucka Embry
regex - Split on first comma in string - Stack Overflow answered by flodel on Apr 25 2012. See https://stackoverflow.com/questions/10309122/split-on-first-comma-in-string.
regex - r regexp - replace title and suffix in any part of string with nothing in large file (> 2 million rows) - Stack Overflow answered by Molx on Apr 16 2015. See https://stackoverflow.com/questions/29680131/r-regexp-replace-title-and-suffix-in-any-part-of-string-with-nothing-in-large.
# Example 1 install.load::load_package("iemisc", "data.table") dtxx <- data.table(Names = c("Cooler, Wine", "Juice, Fruit", "Hard Water", "Hot Bath", "Set, Data")) dtxx[, Corrected_Names := splitcomma(dtxx$Names)] dtxx # Example 2 xtrax <- "FALSER, BRATTIE & SIMX, AGONY" splitcomma(xtrax)# Example 1 install.load::load_package("iemisc", "data.table") dtxx <- data.table(Names = c("Cooler, Wine", "Juice, Fruit", "Hard Water", "Hot Bath", "Set, Data")) dtxx[, Corrected_Names := splitcomma(dtxx$Names)] dtxx # Example 2 xtrax <- "FALSER, BRATTIE & SIMX, AGONY" splitcomma(xtrax)
This function removes characters from a string based on a character vector named remove. This function can be used to remove prefixes, suffixes, titles, etc. from a given character vector. The function splits the string by empty spaces, dots, commas, and parentheses first & then it removes the items that are in the remove vector.
splitremove(string, remove)splitremove(string, remove)
string |
character vector that contains the text to keep and to remove |
remove |
character vector that contains the characters to remove from the string |
the revised character vector with the contents of
remove removed from the string
Irucka Embry
regex - r regexp - replace title and suffix in any part of string with nothing in large file (> 2 million rows) - Stack Overflow answered by Molx on Apr 16 2015. See https://stackoverflow.com/questions/29680131/r-regexp-replace-title-and-suffix-in-any-part-of-string-with-nothing-in-large.
# Example install.load::load_package("iemisc", "data.table") # create the list of items to remove from the text remove <- c("mister", "sir", "mr", "madam", "mrs", "miss", "ms", "iv", "iii", "ii", "jr", "sr", "md", "phd", "mba", "pe", "mrcp", "and", "&", "prof", "professor", "esquire", "esq", "dr", "doctor") names <- data.table(Named = c("Alfredy 'Chipp' Kahner IV", "Denis G. Barnekdt III", "JERUEG, RICHARDS Z. MR.", "EDWARDST, HOWARDD K. JR.")) # first use split comma names[, Corrected_Named := splitcomma(names$Named)] names names[, Corrected_Named := splitremove(names$Corrected_Named, remove)] names# Example install.load::load_package("iemisc", "data.table") # create the list of items to remove from the text remove <- c("mister", "sir", "mr", "madam", "mrs", "miss", "ms", "iv", "iii", "ii", "jr", "sr", "md", "phd", "mba", "pe", "mrcp", "and", "&", "prof", "professor", "esquire", "esq", "dr", "doctor") names <- data.table(Named = c("Alfredy 'Chipp' Kahner IV", "Denis G. Barnekdt III", "JERUEG, RICHARDS Z. MR.", "EDWARDST, HOWARDD K. JR.")) # first use split comma names[, Corrected_Named := splitcomma(names$Named)] names names[, Corrected_Named := splitremove(names$Corrected_Named, remove)] names
This function solves for the surface tension of water using only the temperature of the water in either units of degrees Celsius, degrees Fahrenheit, or Kelvin.
surf_tens_water(Temp, units = c("SI", "Eng", "Absolute"))surf_tens_water(Temp, units = c("SI", "Eng", "Absolute"))
Temp |
numeric vector that contains the temperature (degrees Celsius, degrees Fahrenheit, or Kelvin) |
units |
character vector that contains the system of units (options are
|
The simplified equation is expressed as
with
Water Surface Tension (N/m or lbf/ft)
the water temperature, degrees Celsius
the surface tension as a numeric vector. The units are not returned.
Irucka Embry
C. O. Popiel & J. Wojtkowiak (1998). "Simple Formulas for Thermophysical Properties of Liquid Water for Heat Transfer Calculations (from 0C to 150C)". Heat Transfer Engineering, 19:3, 87-101, article from ResearchGate: https://www.researchgate.net/publication/239243539_Simple_Formulas_for_Thermophysical_Properties_of_Liquid_Water_for_Heat_Transfer_Calculations_from_0C_to_150C.
# Example (Compare to the tabulated values in the Reference paper) install.load::load_package("iemisc", "data.table", "round") Temp <- c(0, 0.01, 3.86, seq(5, 95, by = 5), 99.974, seq(100, 150, by = 5)) surface_tension <- data.table("Temperature (degrees C)" = Temp, "omega (N / m)" = round_r3(surf_tens_water(Temp, units = "SI"), d = 5)); surface_tension# Example (Compare to the tabulated values in the Reference paper) install.load::load_package("iemisc", "data.table", "round") Temp <- c(0, 0.01, 3.86, seq(5, 95, by = 5), 99.974, seq(100, 150, by = 5)) surface_tension <- data.table("Temperature (degrees C)" = Temp, "omega (N / m)" = round_r3(surf_tens_water(Temp, units = "SI"), d = 5)); surface_tension
This function computes the total surface area of linear surfaces (total sum of width x length). This function was created to use in drainage area calculations; however, it can be used in other calculations as well.
surface_area( length = NULL, width = NULL, surface_area_table = NULL, lw_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer") )surface_area( length = NULL, width = NULL, surface_area_table = NULL, lw_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer") )
length |
numeric vector containing the length value(s) in one of the lw_units values. |
width |
numeric vector containing the width value(s) in one of the lw_units values. |
surface_area_table |
data.frame/data.table/tibble, list, or matrix containing the length in column 1 and the width in column 2 |
lw_units |
character vector containing the unit for the length and the width (default = "feet"). The other possible units are "inch", "survey_foot", "yard", "mile", "centimeter", "meter", or "kilometer". |
surface area as a numeric vector in the provided square unit of the lw_units.
Irucka Embry
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.
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.
rain_garden_driveway for calculating the rain garden size for driveways
# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 library(iemisc) length1 <- c(220, 150, 30) width1 <- c(75, 89, 80) surface_area(width = width1, length = length1, lw_units = "meter") # Example 2 library(iemisc) length2 <- c(333, 681, 73) width2 <- c(17.4, 9.5, 8) surface_area_tablew <- list(Length = length2, Width = width2) surface_area(surface_area_table = surface_area_tablew, lw_units = "mile") # See Source 1 and Source 2 # Example 3 library(iemisc) length3 <- c("33 feet 3 1/2 inches", 45) width3 <- c(17, 4) surface_area_tablew <- list(Length = length3, Width = width3) try(surface_area(surface_area_table = surface_area_tablew, lw_units = "mile"))# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 library(iemisc) length1 <- c(220, 150, 30) width1 <- c(75, 89, 80) surface_area(width = width1, length = length1, lw_units = "meter") # Example 2 library(iemisc) length2 <- c(333, 681, 73) width2 <- c(17.4, 9.5, 8) surface_area_tablew <- list(Length = length2, Width = width2) surface_area(surface_area_table = surface_area_tablew, lw_units = "mile") # See Source 1 and Source 2 # Example 3 library(iemisc) length3 <- c("33 feet 3 1/2 inches", 45) width3 <- c(17, 4) surface_area_tablew <- list(Length = length3, Width = width3) try(surface_area(surface_area_table = surface_area_tablew, lw_units = "mile"))
This function computes the total surface volume of linear surfaces (total sum of width x length x depth).
surface_volume( length = NULL, width = NULL, depth = NULL, surface_volume_table = NULL, area = NULL, lw_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer"), depth_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer") )surface_volume( length = NULL, width = NULL, depth = NULL, surface_volume_table = NULL, area = NULL, lw_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer"), depth_units = c("inch", "feet", "survey_foot", "yard", "mile", "centimeter", "meter", "kilometer") )
length |
numeric vector containing the length value(s) in one of the lw_units values. |
width |
numeric vector containing the width value(s) in one of the lw_units values. |
depth |
numeric vector containing the depth value(s) in one of the depth_units values. |
surface_volume_table |
data.frame/data.table/tibble, list, or matrix containing the length in column 1, the width in column 2, and the depth in column 3 |
area |
numeric vector containing the area value(s) in one of the lw_units values. |
lw_units |
character vector containing the unit for the length and the width (default = "feet"). The other possible units are "inch", "survey_foot", "yard", "mile", "centimeter", "meter", or "kilometer". The units should be consistent and not mixed. |
depth_units |
character vector containing the unit for the depth (default = "inch"). The other possible units are "inch", "survey_foot", "yard", "mile", "centimeter", "meter", or "kilometer". |
surface volume as a numeric vector in the provided cubic unit of the lw_units.
Irucka Embry
rain_garden_driveway for calculating the rain garden size for driveways
# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 library(iemisc) length1 <- c(220, 150, 30) width1 <- c(75, 89, 80) depth1 <- c(0.5, 1, 0.675) surface_volume(width = width1, length = length1, depth = depth1, lw_units = "meter", depth_units = "feet") # Example 2 library(iemisc) length2 <- c(333, 681, 73) width2 <- c(17.4, 9.5, 8) depth2 <- c(3, 2.5, 5.6) surface_volume_table1 = list(Length = length2, Width = width2, Depth = depth2) surface_volume(surface_volume_table = surface_volume_table1, lw_units = "mile", depth_units = "inch") # Example 3 library(iemisc) length2 <- c(333, 681, 73) width2 <- c(17.4, 9.5, 8) depth2 <- c(3, 2.5, 5.6) surface_volume_table2 = list(Length = length2, Width = width2, Depth = depth2) surface_volume(surface_volume_table = surface_volume_table2, lw_units = "kilometer", depth_units = "centimeter") # Example 4 library(iemisc) length3 <- c(220, 150, 30) width3 <- c(75, 89, 80) depth3 <- c(0.5 * 12, 1 * 12, 0.675 * 12) # to test with the 1st set surface_volume(width = width3, length = length3, depth = depth3, lw_units = "meter", depth_units = "inch") # Example 5 (Extension of Example 1 from the surface_area function) library(iemisc) area_use <- surface_area(width = width1, length = length1, lw_units = "meter") depth4 <- 2 surface_volume(area = area_use, depth = depth4, lw_units = "meter", depth_units = "centimeter")# Please refer to the iemisc: Construction Measurement Examples vignette for # additional examples # Example 1 library(iemisc) length1 <- c(220, 150, 30) width1 <- c(75, 89, 80) depth1 <- c(0.5, 1, 0.675) surface_volume(width = width1, length = length1, depth = depth1, lw_units = "meter", depth_units = "feet") # Example 2 library(iemisc) length2 <- c(333, 681, 73) width2 <- c(17.4, 9.5, 8) depth2 <- c(3, 2.5, 5.6) surface_volume_table1 = list(Length = length2, Width = width2, Depth = depth2) surface_volume(surface_volume_table = surface_volume_table1, lw_units = "mile", depth_units = "inch") # Example 3 library(iemisc) length2 <- c(333, 681, 73) width2 <- c(17.4, 9.5, 8) depth2 <- c(3, 2.5, 5.6) surface_volume_table2 = list(Length = length2, Width = width2, Depth = depth2) surface_volume(surface_volume_table = surface_volume_table2, lw_units = "kilometer", depth_units = "centimeter") # Example 4 library(iemisc) length3 <- c(220, 150, 30) width3 <- c(75, 89, 80) depth3 <- c(0.5 * 12, 1 * 12, 0.675 * 12) # to test with the 1st set surface_volume(width = width3, length = length3, depth = depth3, lw_units = "meter", depth_units = "inch") # Example 5 (Extension of Example 1 from the surface_area function) library(iemisc) area_use <- surface_area(width = width1, length = length1, lw_units = "meter") depth4 <- 2 surface_volume(area = area_use, depth = depth4, lw_units = "meter", depth_units = "centimeter")
Calculates the value of tangent for each element of x in degrees in a
manner compatible with GNU Octave/MATLAB. Zero is returned for any "elements
where x / 180 is an integer and Inf for elements where
(x - 90) / 180 is an integer." Reference: Eaton.
tand(x)tand(x)
x |
A numeric vector containing values in degrees |
The tangent of each element of x in degrees. Zero for any
"elements where x / 180 is an integer and Inf for elements where
(x - 90) / 180 is an integer."
David Bateman (GNU Octave tand), Irucka Embry
John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (November 2022). GNU Octave: A high-level interactive language for numerical computations: Edition 7 for Octave version 7.3.0. https://docs.octave.org/octave.pdf. Page 553.
tan if you have a radian (rad) angle value
library(iemisc) # Examples from GNU Octave tand tand(seq(10, 80, by = 10)) tand(c(0, 180, 360)) tand(c(90, 270))library(iemisc) # Examples from GNU Octave tand tand(seq(10, 80, by = 10)) tand(c(0, 180, 360)) tand(c(90, 270))
Computes the amount of time given a rate of change and an area's starting and ending values.
time_area_change( area_start, area_end, rate, output = c("basic", "tables"), area_unit = c("acre", "square feet", "square mile", "hectare", "square kilometer", "square yard", "square meter", "square inch", "square millimeter", "square centimeter"), time_unit = c("seconds", "minutes", "hours", "days", "weeks", "months", "years") )time_area_change( area_start, area_end, rate, output = c("basic", "tables"), area_unit = c("acre", "square feet", "square mile", "hectare", "square kilometer", "square yard", "square meter", "square inch", "square millimeter", "square centimeter"), time_unit = c("seconds", "minutes", "hours", "days", "weeks", "months", "years") )
area_start |
numeric or character (can be coerced to numeric) vector that contains the value of the starting area |
area_end |
numeric or character (can be coerced to numeric) vector that contains the value of the ending area |
rate |
numeric or character (can be coerced to numeric) vector that contains the rate of change for the given area |
output |
character vector that contains the output type ("basic" or
"tables"), either it will be a |
area_unit |
character vector containing the units for area (area_start and area_end should have the same units). The default area_unit = "acre". The other possible units are "square feet", "square mile", "hectare", "square kilometer", "square yard", "square meter", "square inch", "square millimeter", or "square centimeter". "seconds"). The other possible units are "minutes", "hours", "days", "weeks", "months", or "years". |
the time numeric vector when the output is basic or return a list of data.tables when the output is tables. There will be 2 tables (Time & Area). The Time table consists of the Time and Units columns. The calculated time value is converted to seconds, minutes, hours, days, weeks, months, and years. The Area table contains the Area Start, Area End, and Units columns. If the area difference (start - end) is >= 1, the original area values will be converted to acres, square feet, square miles, hectares, square kilometers, square yards, and square meters. Otherwise, the original area values will be converted to square inches, square millimeters, and square centimeters.
Irucka Embry
SCFM (South Cumberland Farmers Market). Newsletter: "Tennessee ranks third in the nation for agricultural land loss... The Farmland Preservation Bill could help. Lots to look out for... new veggies, updates from SeTNYF, and a little bit on The Farmland Preservation Bill and how to support it." By Liz Calabria and Rooted Here, Feb 16, 2025, https://scfm.substack.com/p/updates-from-setnyf-and-new-farm.
United States Department of Agriculture (USDA) National Agricultural Statistics Service (NASS). 2023 State Agriculture Overview for Tennessee, https://web.archive.org/web/20240331222922/https://www.nass.usda.gov/Quick_Stats/Ag_Overview/stateOverview.php?state=TENNESSEE.
United States Department of Agriculture (USDA) National Agricultural Statistics Service (NASS). 2024 State Agriculture Overview for Tennessee, https://web.archive.org/web/20250421004820/https://www.nass.usda.gov/Quick_Stats/Ag_Overview/stateOverview.php?state=Tennessee.
# Example 1 # Given # Tennessee lost farmland between 2017 and 2023 "at a rate of 9.8 acres per # hour" (Reference 1) # In 2023 (and in 2024), there were 10,700,000 acres of land operated as # farmland in Tennessee (References 2 and 3 -- I wonder how there can still # be the same amount of farmland in 2024 as in 2023 if there still has been # the significant loss of farmland each hour.) # Question # If the rate of farmland loss continues unabated, how long will it take for # Tennessee to lose all of its 2023 farmland acreage? # Solve the problem library(iemisc) rate1 <- 9.8 area_start1 <- "10,700,000" area_end1 <- 0 output1 <- "tables" area_unit1 <- "acre" time_unit1 <- "hours" time_area_change(area_start = area_start1, area_end = area_end1, rate = rate1, output = output1, area_unit = area_unit1, time_unit = time_unit1) # Example 2 library(iemisc) rate2 <- 0.01 area_start2 <- "0" area_end2 <- 4 output2 <- "basic" area_unit2 <- "square centimeter" time_unit2 <- "minutes" time_area_change(area_start = area_start2, area_end = area_end2, rate = rate2, output = output2, area_unit = area_unit2, time_unit = time_unit2) # Example 3 library(iemisc) rate3 <- "0.041" area_start3 <- "0.02" area_end3 <- 2.03 output3 <- "tables" area_unit3 <- "square inch" time_unit3 <- "seconds" time_area_change(area_start = area_start3, area_end = area_end3, rate = rate3, output = output3, area_unit = area_unit3, time_unit = time_unit3)# Example 1 # Given # Tennessee lost farmland between 2017 and 2023 "at a rate of 9.8 acres per # hour" (Reference 1) # In 2023 (and in 2024), there were 10,700,000 acres of land operated as # farmland in Tennessee (References 2 and 3 -- I wonder how there can still # be the same amount of farmland in 2024 as in 2023 if there still has been # the significant loss of farmland each hour.) # Question # If the rate of farmland loss continues unabated, how long will it take for # Tennessee to lose all of its 2023 farmland acreage? # Solve the problem library(iemisc) rate1 <- 9.8 area_start1 <- "10,700,000" area_end1 <- 0 output1 <- "tables" area_unit1 <- "acre" time_unit1 <- "hours" time_area_change(area_start = area_start1, area_end = area_end1, rate = rate1, output = output1, area_unit = area_unit1, time_unit = time_unit1) # Example 2 library(iemisc) rate2 <- 0.01 area_start2 <- "0" area_end2 <- 4 output2 <- "basic" area_unit2 <- "square centimeter" time_unit2 <- "minutes" time_area_change(area_start = area_start2, area_end = area_end2, rate = rate2, output = output2, area_unit = area_unit2, time_unit = time_unit2) # Example 3 library(iemisc) rate3 <- "0.041" area_start3 <- "0.02" area_end3 <- 2.03 output3 <- "tables" area_unit3 <- "square inch" time_unit3 <- "seconds" time_area_change(area_start = area_start3, area_end = area_end3, rate = rate3, output = output3, area_unit = area_unit3, time_unit = time_unit3)
This function computes the composite CN (Curve Number) for unconnected impervious areas and total impervious areas less than 30 percent.
uc_composite_CN(pervious_CN, impervious, R)uc_composite_CN(pervious_CN, impervious, R)
pervious_CN |
numeric vector containing the pervious runoff curve number |
impervious |
numeric vector containing the percent imperviousness |
R |
numeric vector containing the ratio of unconnected impervious area to total impervious area |
the Composite Runoff Curve Number as a single numeric vector, in the range [0, 100]
Irucka Embry
United States Department of Agriculture Natural Resources Conservation Service Conservation Engineering Division, "Urban Hydrology for Small Watersheds Technical Release 55 (TR-55)", June 1986, pages 2-11 - 2-16, https://web.archive.org/web/20230810204711/https://directives.sc.egov.usda.gov/OpenNonWebContent.aspx?content=22162.wba [Recovered with the Internet Archive: Wayback Machine]
# Please refer to iemiscdata: Weighted CN Calculations Using the Composite CN # vignette in the iemiscdata package# Please refer to iemiscdata: Weighted CN Calculations Using the Composite CN # vignette in the iemiscdata package
This function solves for the unit weight or specific weight of a substance using only the substance's density and gravitational acceleration.
unit_wt(rho, units = c("SI", "Eng"), Eng_units = c("slug/ft^3", "lbm/ft^3"))unit_wt(rho, units = c("SI", "Eng"), Eng_units = c("slug/ft^3", "lbm/ft^3"))
rho |
numeric vector that contains the density |
units |
character vector that contains the system of units [options are
|
Eng_units |
character vector that contains the density English units
[options are |
The equation is expressed as
unit weight or specific weight (N/m^3 or lbf/ft^3)
substance mass (kg, lbm, or slugs)
gravitational acceleration (m/s^2 or ft/sec^2)
"unit conversion factor used to convert mass to force or vice versa" (lbm-ft/lbf-sec^2)
the volume of the substance (m^3 or ft^3)
substance density (mass divided by volume) [kg/m^3, slug/ft^3", or lbm/ft^3]
the unit weight or specific weight as a numeric vector. The units are not returned.
Irucka Embry
The Engineering ToolBox, 27 March 2022, "Water - Density, Specific Weight and Thermal Expansion Coefficients", https://www.engineeringtoolbox.com/water-density-specific-weight-d_595.html
WikiEngineer, 27 March 2022, "Water Properties & Definitions", https://web.archive.org/web/20210412034245/http://www.wikiengineer.com/Water-Resources/PropertiesAndDefinitions. Retrieved thanks to the Internet Archive: Wayback Machine
Wikimedia Foundation, Inc. Wikipedia, 27 March 2022, "gc (engineering)", https://en.wikipedia.org/wiki/Gc_(engineering).
Wikimedia Foundation, Inc. Wikipedia, 27 March 2022, "Specific weight", https://en.wikipedia.org/wiki/Specific_weight.
# Examples library(iemisc) rho1 <- density_water(Temp = 68, units = "Eng", Eng_units = "slug/ft^3") unit_wt(rho = rho1, units = "Eng", Eng_units = "slug/ft^3") rho2 <- density_water(Temp = 68, units = "Eng", Eng_units = "lbm/ft^3") unit_wt(rho = rho2, units = "Eng", Eng_units = "lbm/ft^3") rho3 <- density_water(Temp = 20, units = "SI") unit_wt(rho = rho3, units = "SI")# Examples library(iemisc) rho1 <- density_water(Temp = 68, units = "Eng", Eng_units = "slug/ft^3") unit_wt(rho = rho1, units = "Eng", Eng_units = "slug/ft^3") rho2 <- density_water(Temp = 68, units = "Eng", Eng_units = "lbm/ft^3") unit_wt(rho = rho2, units = "Eng", Eng_units = "lbm/ft^3") rho3 <- density_water(Temp = 20, units = "SI") unit_wt(rho = rho3, units = "SI")
This function computes the volume of a sphere using a given radius.
volsphere(r)volsphere(r)
r |
numeric vector, matrix, data.frame, or data.table that contains the radius of a sphere. |
The radius of a sphere is "the integral of the surface area of a sphere."
Volume of a sphere is expressed as
the volume of a sphere
the radius of a sphere
volume of a sphere (as L^3 units) as an R object: a numeric vector
or a named numeric vector if using a named object (matrix, data.frame,
or data.table).
Irucka Embry
Wikimedia Foundation, Inc. Wikipedia, 30 December 2015, "Volume", https://en.wikipedia.org/wiki/Volume.
install.load::load_package("iemisc", "data.table") volsphere(3) # in volsphere(4.5) # in x <- c(3, 4, 0.2, 12, 34, 7.5) # cm volsphere(x) # using a matrix of the numeric vector x mat1 <- matrix(data = x, nrow = length(x), ncol = 1, byrow = FALSE, dimnames = list(c(rep("", length(x))), "Radius")) volsphere(mat1) # using a data.frame of the numeric vector x df1 <- data.frame(x) volsphere(df1) # using a data.table of the numeric vector x df2 <- data.table(x) volsphere(df2)install.load::load_package("iemisc", "data.table") volsphere(3) # in volsphere(4.5) # in x <- c(3, 4, 0.2, 12, 34, 7.5) # cm volsphere(x) # using a matrix of the numeric vector x mat1 <- matrix(data = x, nrow = length(x), ncol = 1, byrow = FALSE, dimnames = list(c(rep("", length(x))), "Radius")) volsphere(mat1) # using a data.frame of the numeric vector x df1 <- data.frame(x) volsphere(df1) # using a data.table of the numeric vector x df2 <- data.table(x) volsphere(df2)
This function computes the weighted C factor using the user-supplied unit or the default unit of an acre for use in the Rational Formula.
weighted_C( C = NULL, area = NULL, area_pct = NULL, area_units = c("acre", "square feet", "square mile", "hectare", "square kilometer"), C_area_table = NULL, C_area_pct_table = NULL )weighted_C( C = NULL, area = NULL, area_pct = NULL, area_units = c("acre", "square feet", "square mile", "hectare", "square kilometer"), C_area_table = NULL, C_area_pct_table = NULL )
C |
numeric vector containing dimensionless C factor(s) |
area |
numeric vector containing the surface land area |
area_pct |
numeric vector containing the surface land area, as a percent (decimal or whole number) |
area_units |
character vector containing the units for area (default = "acre"). The other possible units are "square feet", "square mile", "hectare", or "square kilometer". The units should be consistent and not mixed. |
C_area_table |
data.frame/data.table/tibble, list, or matrix containing the C in column 1 and the area in column 2 |
C_area_pct_table |
data.frame/data.table/tibble, list, or matrix containing the C in column 1 and the area_pct in column 2 |
Weighted C factor as a single numeric vector, in the range [0, 1]
Irucka Embry
Engineering Hydrology Training Series Module 104 - Runoff Curve Number Computations Study Guide, United States Department of Agriculture Soil Conservation Service National Employee Development Staff, September 1989, page 21 https://web.archive.org/web/20210414043852/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/training/runoff-curve-numbers1.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
# Note: the default area unit is acre # Example 1 library(iemisc) area1 <- c(220, 150, 30) C1 <- c(75, 89, 80) weighted_C(C = C1, area = area1) # Example 2 library(iemisc) area2 <- c(220, 150, 30) area_pct2 <- area2 / sum(area2) C2 <- c(80, 95, 80) C_area_pct_table2 <- data.frame(C2, area_pct2) weighted_C(C_area_pct_table = C_area_pct_table2) # Example 3 install.load::load_package("iemisc", "data.table") C_area_table3 <- data.table(C = c(98, 100, 45), area = c(2.53, 453.00, 0.21)) weighted_C(C_area_table = C_area_table3) # Example 4 library(iemisc) C4 <- c(98, 100, 45) area_pct4 <- c(0.15, 0.23, 0.62) weighted_C(C = C4, area_pct = area_pct4) # Example 5 library(iemisc) data_matrix5a <- matrix(c(98, 30, 40, 43, 57, 3.24, 1, 30, 50, 123), nrow = 5, ncol = 2, dimnames = list(rep("", 5), c("C", "Area"))) weighted_C(C_area_table = data_matrix5a) # using ramify to create the matrix import::from(ramify, mat) data_matrix5b <- mat("98 30 40 43 57;3.24 1 30 50 123", rows = FALSE, sep = " ", dimnames = list(rep("", 5), c("C", "Area"))) weighted_C(C_area_table = data_matrix5b) # Example 6 - using area in square feet library(iemisc) data_list6 <- list(C = c(77, 29, 68), Area = c(43560, 56893, 345329.32)) weighted_C(C_area_table = data_list6, area_units = "square feet") # Example 7 install.load::load_package("iemisc", "data.table") # Impervious area - 3.04 acre # 45% of total area # 0.80 C Factor # Pervious area - 4.67 acre # 55% of total area # 0.20 C factor C_area_table7 <- data.table(C = c(0.80, 0.20), area = c(3.04, 4.67)) weighted_C(C_area_table = C_area_table7) # Example 8 # Impervious area - 2.44 acre # 32% of total area # 0.80 C Factor # Pervious area - 5.03 acre # 68% of total area # 0.20 C factor C8 <- c(0.80, 0.20) area_pct8 <- c(0.32, 0.68) weighted_C(C = C8, area_pct = area_pct8) # Example 9 library(iemisc) # Medium density residential area - 30 hectares (75.0% of total area), # 0.31 - 0.40 C factor # High density residential area - 3 hectares (7.50% of total area), # 0.49 - 0.60 C factor # Agricultural area - 7 hectares (17.5% of total area), 0.15 - 0.21 C factor C3 <- c(mean(seq(0.31, 0.40, by = 0.01)), mean(seq(0.49, 0.60, by = 0.01)), mean(seq(0.15, 0.21, by = 0.01))) area3 <- c(30, 3, 7) weighted_C(C = C3, area = area3, area_units = "hectare")# Note: the default area unit is acre # Example 1 library(iemisc) area1 <- c(220, 150, 30) C1 <- c(75, 89, 80) weighted_C(C = C1, area = area1) # Example 2 library(iemisc) area2 <- c(220, 150, 30) area_pct2 <- area2 / sum(area2) C2 <- c(80, 95, 80) C_area_pct_table2 <- data.frame(C2, area_pct2) weighted_C(C_area_pct_table = C_area_pct_table2) # Example 3 install.load::load_package("iemisc", "data.table") C_area_table3 <- data.table(C = c(98, 100, 45), area = c(2.53, 453.00, 0.21)) weighted_C(C_area_table = C_area_table3) # Example 4 library(iemisc) C4 <- c(98, 100, 45) area_pct4 <- c(0.15, 0.23, 0.62) weighted_C(C = C4, area_pct = area_pct4) # Example 5 library(iemisc) data_matrix5a <- matrix(c(98, 30, 40, 43, 57, 3.24, 1, 30, 50, 123), nrow = 5, ncol = 2, dimnames = list(rep("", 5), c("C", "Area"))) weighted_C(C_area_table = data_matrix5a) # using ramify to create the matrix import::from(ramify, mat) data_matrix5b <- mat("98 30 40 43 57;3.24 1 30 50 123", rows = FALSE, sep = " ", dimnames = list(rep("", 5), c("C", "Area"))) weighted_C(C_area_table = data_matrix5b) # Example 6 - using area in square feet library(iemisc) data_list6 <- list(C = c(77, 29, 68), Area = c(43560, 56893, 345329.32)) weighted_C(C_area_table = data_list6, area_units = "square feet") # Example 7 install.load::load_package("iemisc", "data.table") # Impervious area - 3.04 acre # 45% of total area # 0.80 C Factor # Pervious area - 4.67 acre # 55% of total area # 0.20 C factor C_area_table7 <- data.table(C = c(0.80, 0.20), area = c(3.04, 4.67)) weighted_C(C_area_table = C_area_table7) # Example 8 # Impervious area - 2.44 acre # 32% of total area # 0.80 C Factor # Pervious area - 5.03 acre # 68% of total area # 0.20 C factor C8 <- c(0.80, 0.20) area_pct8 <- c(0.32, 0.68) weighted_C(C = C8, area_pct = area_pct8) # Example 9 library(iemisc) # Medium density residential area - 30 hectares (75.0% of total area), # 0.31 - 0.40 C factor # High density residential area - 3 hectares (7.50% of total area), # 0.49 - 0.60 C factor # Agricultural area - 7 hectares (17.5% of total area), 0.15 - 0.21 C factor C3 <- c(mean(seq(0.31, 0.40, by = 0.01)), mean(seq(0.49, 0.60, by = 0.01)), mean(seq(0.15, 0.21, by = 0.01))) area3 <- c(30, 3, 7) weighted_C(C = C3, area = area3, area_units = "hectare")
This function computes the weighted CN (Curve Number) using the user-supplied unit or the default unit of an acre.
weighted_CN( CN = NULL, CN_area_table = NULL, CN_area_pct_table = NULL, area = NULL, area_pct = NULL, area_units = c("acre", "square feet", "square mile", "hectare", "square kilometer") )weighted_CN( CN = NULL, CN_area_table = NULL, CN_area_pct_table = NULL, area = NULL, area_pct = NULL, area_units = c("acre", "square feet", "square mile", "hectare", "square kilometer") )
CN |
numeric vector containing dimensionless Curve Number(s) |
CN_area_table |
data.frame/data.table/tibble, list, or matrix containing the CN in column 1 and the area in column 2 |
CN_area_pct_table |
data.frame/data.table/tibble, list, or matrix containing the CN in column 1 and the area_pct in column 2 |
area |
numeric vector containing the surface land area |
area_pct |
numeric vector containing the surface land area, as a percent (decimal or whole number) |
area_units |
character vector containing the units for area (default = "acre"). The other possible units are "square feet", "square mile", "hectare", or "square kilometer". The units should be consistent and not mixed. |
the Weighted Curve Number as a single numeric vector, in the range [0, 100]
This function was originally part of Claudia Vitolo's curvenumber package
that Irucka now maintains.
Irucka Embry
United States Department of Agriculture Soil Conservation Service National Employee Development Staff, "Engineering Hydrology Training Series Module 104 - Runoff Curve Number Computations Study Guide", September 1989, page 21, https://web.archive.org/web/20210414043852/https://www.wcc.nrcs.usda.gov/ftpref/wntsc/H&H/training/runoff-curve-numbers1.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
Dr. Clyde Munster, P.E., Texas A&M University Department of Biological and Agricultural Engineering, "Rational Method: Calculating Peak Flow Rates", https://web.archive.org/web/20180218221234/http://munster.tamu.edu/Study_Abroad/BAEN460_AGSM335/PowerPoint/RationalMethod_5.pdf. Retrieved thanks to the Internet Archive: Wayback Machine
United States Department of Agriculture Natural Resources Conservation Service Conservation Engineering Division, "Urban Hydrology for Small Watersheds Technical Release 55 (TR-55)", June 1986, https://web.archive.org/web/20230810204711/https://directives.sc.egov.usda.gov/OpenNonWebContent.aspx?content=22162.wba [Recovered with the Internet Archive: Wayback Machine]
# Note: the default area unit is an acre # Example 1 library(iemisc) area1 <- c(220, 150, 30) CN1 <- c(75, 89, 80) weighted_CN(CN = CN1, area = area1) # Example 2 library(iemisc) area2 <- c(220, 150, 30) area_pct2 <- area2 / sum(area2) CN2 <- c(80, 95, 80) CN_area_pct_table2 <- data.frame(CN2, area_pct2) weighted_CN(CN_area_pct_table = CN_area_pct_table2) # Example 3 install.load::load_package("iemisc", "data.table") CN_area_table3 <- data.table(CN = c(98, 100, 45), area = c(2.53, 453.00, 0.21)) weighted_CN(CN_area_table = CN_area_table3) # Example 4 library(iemisc) CN4 <- c(98, 100, 45) area_pct4 <- c(0.15, 0.23, 0.62) weighted_CN(CN = CN4, area_pct = area_pct4) # Example 5 library(iemisc) import::from(ramify, mat) data_matrix5a <- matrix(c(98, 30, 40, 43, 57, 3.24, 1, 30, 50, 123), nrow = 5, ncol = 2, dimnames = list(rep("", 5), c("C", "Area"))) weighted_CN(CN_area_table = data_matrix5a) # using ramify to create the matrix data_matrix5b <- mat("98 30 40 43 57;3.24 1 30 50 123", rows = FALSE, sep = " ", dimnames = list(rep("", 5), c("CN", "Area"))) weighted_CN(CN_area_table = data_matrix5b) # Example 6 - using area in square feet library(iemisc) data_list6 <- list(CN = c(77, 29, 68), Area = c(43560, 56893, 345329.32)) weighted_CN(CN_area_table = data_list6, area_units = "square feet") # Example 7 - using area in whole percents library(iemisc) CN7 <- c(61, 74) area_pct7 <- c(30, 70) weighted_CN(CN = CN7, area_pct = area_pct7)# Note: the default area unit is an acre # Example 1 library(iemisc) area1 <- c(220, 150, 30) CN1 <- c(75, 89, 80) weighted_CN(CN = CN1, area = area1) # Example 2 library(iemisc) area2 <- c(220, 150, 30) area_pct2 <- area2 / sum(area2) CN2 <- c(80, 95, 80) CN_area_pct_table2 <- data.frame(CN2, area_pct2) weighted_CN(CN_area_pct_table = CN_area_pct_table2) # Example 3 install.load::load_package("iemisc", "data.table") CN_area_table3 <- data.table(CN = c(98, 100, 45), area = c(2.53, 453.00, 0.21)) weighted_CN(CN_area_table = CN_area_table3) # Example 4 library(iemisc) CN4 <- c(98, 100, 45) area_pct4 <- c(0.15, 0.23, 0.62) weighted_CN(CN = CN4, area_pct = area_pct4) # Example 5 library(iemisc) import::from(ramify, mat) data_matrix5a <- matrix(c(98, 30, 40, 43, 57, 3.24, 1, 30, 50, 123), nrow = 5, ncol = 2, dimnames = list(rep("", 5), c("C", "Area"))) weighted_CN(CN_area_table = data_matrix5a) # using ramify to create the matrix data_matrix5b <- mat("98 30 40 43 57;3.24 1 30 50 123", rows = FALSE, sep = " ", dimnames = list(rep("", 5), c("CN", "Area"))) weighted_CN(CN_area_table = data_matrix5b) # Example 6 - using area in square feet library(iemisc) data_list6 <- list(CN = c(77, 29, 68), Area = c(43560, 56893, 345329.32)) weighted_CN(CN_area_table = data_list6, area_units = "square feet") # Example 7 - using area in whole percents library(iemisc) CN7 <- c(61, 74) area_pct7 <- c(30, 70) weighted_CN(CN = CN7, area_pct = area_pct7)
Which Median
which_median(x)which_median(x)
Irucka Embry, cbeleites
Stack Overflow, "r - Function for median similar to "which.max" and "which.min" / Extracting median rows from a djp_V1_V2a.frame" Answered & edited by cbeleites on Apr 21, 2012, ‘https://stackoverflow.com/questions/10256503/function-for-median-similar-to-which-max-and-which-min-extracting-median-r’.