diff --git a/R/calibration.R b/R/calibration.R index d74c522..1e84ba9 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -8,8 +8,8 @@ #' (LOD) and limit of quantification (LOQ) in accordance with DIN 32645 (2008). #' #' The LOD is defined as the lowest quantity of a substance that can be -#' distinguished from the absence of that substance (blank value) within a -#' given confidence level (\code{alpha}). The LOQ is defined as the lowest quantity of +#' distinguished from the absence of that substance (blank value) within a given +#' confidence level (\code{alpha}). The LOQ is defined as the lowest quantity of #' a substance that can be quantified/distinguished from another sample given #' with respect to a defined confidence level (\code{k}). #' @@ -47,10 +47,10 @@ #' #' @return #' \code{calibration} returns an object of \code{\link[base]{class}} -#' '\code{calibration}'. \code{print()} calls the function parameters together with the -#' respective LOD and LOQ. \code{plot()} plots the respective calibration curve -#' together with the measurement values. \code{summary()} may be used to retrieve -#' the summary of the underlying model. +#' '\code{calibration}'. \code{print()} calls the function parameters together +#' with the respective LOD and LOQ. \code{plot()} plots the respective +#' calibration curve together with the measurement values. \code{summary()} may +#' be used to retrieve the summary of the underlying model. #' #' @author #' Zacharias Steinmetz @@ -69,8 +69,8 @@ #' 215-222. \doi{10.1016/S1570-0232(02)00244-1}. #' #' Currie, L.A. (1999). Nomenclature in evaluation of analytical methods -#' including detection and quantification capabilities: -#' (IUPAC Recommendations 1995). \emph{Analytica Chimica Acta} \bold{391}, 105-126. +#' including detection and quantification capabilities: (IUPAC Recommendations +#' 1995). \emph{Analytica Chimica Acta} \bold{391}, 105-126. #' #' DIN 32645 (2008). \emph{Chemical analysis - Decision limit, detection limit #' and determination limit under repeatability conditions - Terms, methods, @@ -106,7 +106,8 @@ calibration <- function(formula, data = NULL, blanks = NULL, weights = NULL, } } - model <- do.call(model, list(formula = formula, data = newdata, weights = newweights, ...)) + model <- do.call(model, list(formula = formula, data = newdata, + weights = newweights, ...)) model$call <- match.call(expand.dots = F) model$formula <- formula @@ -177,9 +178,11 @@ plot.calibration <- function(x, interval = "conf", level = 0.95, ...) { model <- x$model conc <- model$model[,2] - new <- data.frame(conc = seq(min(conc), max(conc), length.out = 100 * length(conc))) + new <- data.frame(conc = seq(min(conc), max(conc), + length.out = 100 * length(conc))) names(new) <- all.vars(model$formula)[2] - pred <- data.frame(new, predict(x$model, new, interval = interval, level = level)) + pred <- data.frame(new, predict(x$model, new, interval = interval, + level = level)) plot(model$formula, data = model$model, ...) lines(pred[, 2] ~ pred[, 1]) diff --git a/R/theme_publish.R b/R/theme_publish.R index 1176896..2fc43c1 100644 --- a/R/theme_publish.R +++ b/R/theme_publish.R @@ -15,9 +15,9 @@ #' Zacharias Steinmetz #' #' @examples -#' require(ggplot2) +#' library(ggplot2) #' p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg, -#' colour=factor(gear))) + facet_wrap( ~ am) +#' colour = factor(gear))) + facet_wrap( ~ am) #' p #' p + theme_publish() #' diff --git a/README.md b/README.md index 854e264..79ed275 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ analysis in environmental chemistry and ecotoxicology. Provides, for example, `calibration()` to calculate calibration curves and corresponding limits of detection (LODs) and limits of quantification (LOQs) according to German DIN 32645 (2008). `texture()` makes it easy to estimate soil particle size -distributions from hydrometer measurements (ASTM D422-63, 2007). -Some functions of the package require **ggplot2** or **drc**. +distributions from hydrometer measurements (ASTM D422-63, 2007). Some functions +of the package require **ggplot2** or **drc**. ## Functions -Currently, the following functions are available: +The following functions are available: ### Data manipulation and analysis @@ -34,8 +34,7 @@ Currently, the following functions are available: * Determine particle size distributions and soil texture classes (DIN/USDA) measured with a soil hydrometer in accordance with ASTM D422-63 (2007) using `texture()`; see - [vignette](https://htmlpreview.github.io/?https://github.com/zsteinmetz/envalysis/blob/master/vignettes/texture.html) - for details + [vignette](https://zsteinmetz.de/envalysis/articles/texture.html) for details * Confidence intervals `CI()`, standard errors `se()`, and root mean square errors `rmse()` * Various sorption isotherms `sorption()` @@ -48,7 +47,7 @@ Currently, the following functions are available: significant digit, using `signifig()` * Clean, black-and-white ggplot2 theme for scientific publications `theme_publish()`; a preview is available - [here](https://htmlpreview.github.io/?https://github.com/zsteinmetz/envalysis/blob/master/vignettes/theme_publish.html) + [here](https://zsteinmetz.de/envalysis/articles/theme_publish.html) ## Installation @@ -57,7 +56,7 @@ Currently, the following functions are available: ### Install from CRAN (stable version) You can install the released version of **envalysis** from -[CRAN](https://CRAN.R-project.org) with: +[CRAN](https://cran.r-project.org/package=envalysis) with: ```r install.packages("envalysis") diff --git a/man/calibration.Rd b/man/calibration.Rd index ebffe8d..b89c26c 100644 --- a/man/calibration.Rd +++ b/man/calibration.Rd @@ -92,10 +92,10 @@ to calculate the LOQ.} } \value{ \code{calibration} returns an object of \code{\link[base]{class}} -'\code{calibration}'. \code{print()} calls the function parameters together with the -respective LOD and LOQ. \code{plot()} plots the respective calibration curve -together with the measurement values. \code{summary()} may be used to retrieve -the summary of the underlying model. +'\code{calibration}'. \code{print()} calls the function parameters together +with the respective LOD and LOQ. \code{plot()} plots the respective +calibration curve together with the measurement values. \code{summary()} may +be used to retrieve the summary of the underlying model. } \description{ Defines a \code{calibration} object for the calculation of concentrations @@ -103,8 +103,8 @@ from measurement signals including estimations for the limit of detection (LOD) and limit of quantification (LOQ) in accordance with DIN 32645 (2008). The LOD is defined as the lowest quantity of a substance that can be -distinguished from the absence of that substance (blank value) within a -given confidence level (\code{alpha}). The LOQ is defined as the lowest quantity of +distinguished from the absence of that substance (blank value) within a given +confidence level (\code{alpha}). The LOQ is defined as the lowest quantity of a substance that can be quantified/distinguished from another sample given with respect to a defined confidence level (\code{k}). } @@ -136,8 +136,8 @@ bioanalytical methods. \emph{Journal of Chromatography B}, \bold{774}(2), 215-222. \doi{10.1016/S1570-0232(02)00244-1}. Currie, L.A. (1999). Nomenclature in evaluation of analytical methods -including detection and quantification capabilities: -(IUPAC Recommendations 1995). \emph{Analytica Chimica Acta} \bold{391}, 105-126. +including detection and quantification capabilities: (IUPAC Recommendations +1995). \emph{Analytica Chimica Acta} \bold{391}, 105-126. DIN 32645 (2008). \emph{Chemical analysis - Decision limit, detection limit and determination limit under repeatability conditions - Terms, methods, diff --git a/man/envalysis-package.Rd b/man/envalysis-package.Rd index fc48560..1eddd3a 100644 --- a/man/envalysis-package.Rd +++ b/man/envalysis-package.Rd @@ -25,6 +25,7 @@ Springer, New York. Useful links: \itemize{ \item \url{https://github.com/zsteinmetz/envalysis} + \item \url{https://zsteinmetz.de/envalysis/} \item Report bugs at \url{https://github.com/zsteinmetz/envalysis/issues} } diff --git a/man/theme_publish.Rd b/man/theme_publish.Rd index 5be8718..4989910 100644 --- a/man/theme_publish.Rd +++ b/man/theme_publish.Rd @@ -22,9 +22,9 @@ based on the classic dark-on-light ggplot2 \code{\link[ggplot2]{theme_bw}} and has been used for scientific publications. } \examples{ -require(ggplot2) +library(ggplot2) p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg, - colour=factor(gear))) + facet_wrap( ~ am) + colour = factor(gear))) + facet_wrap( ~ am) p p + theme_publish() diff --git a/vignettes/texture.R b/vignettes/texture.R index 067b1ab..cd6ac57 100644 --- a/vignettes/texture.R +++ b/vignettes/texture.R @@ -19,7 +19,6 @@ tex <- texture(reading ~ blank + time + temperature, clayloam, plot = T) tex ## ----classify----------------------------------------------------------------- -# Load soiltexture library(soiltexture) # Prepare data diff --git a/vignettes/texture.Rmd b/vignettes/texture.Rmd index d18e6de..b526fc6 100644 --- a/vignettes/texture.Rmd +++ b/vignettes/texture.Rmd @@ -1,5 +1,7 @@ --- -title: "Particle size estimation using the hydrometer method modified from ASTM D422-63 (2007) and Bouyoucos (1927)" +title: "Particle size estimation with `texture()`" +subtitle: > + Based on the hydrometer method by ASTM D422-63 (2007) and Bouyoucos (1927) author: "Zacharias Steinmetz" date: "`r Sys.Date()`" output: @@ -49,36 +51,33 @@ knitr::opts_chunk$set( ### Dispersing solution -Dissolve 40 g of SHMP in 1 L of deionized water. -To facilitate complete dissolution, fill a 1 L volumetric flask with about -500 mL of deionized water and add the SHMP step-by-step -while stirring the solution with a magnetic stirrer. -The solution is stable for at least one month. +Dissolve 40 g of SHMP in 1 L of deionized water. To facilitate complete +dissolution, fill a 1 L volumetric flask with about 500 mL of deionized water +and add the SHMP step-by-step while stirring the solution with a magnetic +stirrer. The solution is stable for at least one month. ### Calibration -Hydrometers are graduated to be read at the bottom of the meniscus. -However, readings may need be taken at the top of the meniscus in opaque -soil suspensions. +Hydrometers are graduated to be read at the bottom of the meniscus. However, +readings may need be taken at the top of the meniscus in opaque soil +suspensions. -Lower the hydrometer into a 1 L cylinder filled with 125 mL of SHMP solution -and 875 mL of deionized water. -When stabilized (after about 20 s), record both the reading at the bottom (zero -or composite correction factor) and at the top of the meniscus -(meniscus correction factor). +Lower the hydrometer into a 1 L cylinder filled with 125 mL of SHMP solution and +875 mL of deionized water. When stabilized (after about 20 s), record both the +reading at the bottom (zero or composite correction factor) and at the top of +the meniscus (meniscus correction factor). ### Sample pretreatment -If the soil sample contains primarily clay or silt, weigh out 50 g of -soil (accuracy ± 0.01 g) in a 500 mL screw bottle (in 3-fold -replication). If the sample is sandy, take 100 g each. Add 125 mL SHMP solution -to the soil. Agitate the mixture for 16 h (or overnight) in a horizontal shaker. +If the soil sample contains primarily clay or silt, weigh out 50 g of soil +(accuracy ± 0.01 g) in a 500 mL screw bottle (in 3-fold replication). If the +sample is sandy, take 100 g each. Add 125 mL SHMP solution to the soil. Agitate +the mixture for 16 h (or overnight) in a horizontal shaker. -Completely transfer the soil slurry into the 1 L sedimentation cylinder -using a squirt bottle. Fill up to the 1 L mark with deionized water. -Cap the cylinder with parafilm (ensure tightness). -Agitate the slurry by turning the cylinder upside down and back 30 times -during 1 min. +Completely transfer the soil slurry into the 1 L sedimentation cylinder using a +squirt bottle. Fill up to the 1 L mark with deionized water. Cap the cylinder +with parafilm (ensure tightness). Agitate the slurry by turning the cylinder +upside down and back 30 times during 1 min. ### Measurement @@ -117,11 +116,10 @@ The following table may serve as a sample template to record the data ### Data evaluation -A complete description of how to calculate the particle size -distribution from the recorded hydrometer readings is available in the -respective ASTM guideline (ASTM D422-63, 2007). The -algorithm has also been implemented into this package using the `texture()` -function: +A complete description of how to calculate the particle size distribution from +the recorded hydrometer readings is available in the respective ASTM guideline +(ASTM D422-63, 2007). The algorithm has also been implemented into this package +using the `texture()` function. ```{r texture} # Load envalysis @@ -140,7 +138,6 @@ Further soil classification and plotting may be done with the **soiltexture** package. ```{r classify} -# Load soiltexture library(soiltexture) # Prepare data @@ -162,16 +159,19 @@ The analyzed soil is a clay loam (German: "Toniger Lehm", Lt2). ## References -Ashworth, J., Keyes, D., Kirk, R., & Lessard, R. (2001). Standard Procedure in the -Hydrometer Method for Particle Size Analysis. *Communications in Soil Science and -Plant Analysis* **32**, 633-642. DOI: [10.1081/CSS-100103897](https://doi.org/10.1081/CSS-100103897). +Ashworth, J., Keyes, D., Kirk, R., & Lessard, R. (2001). Standard Procedure in +the Hydrometer Method for Particle Size Analysis. *Communications in Soil +Science and Plant Analysis* **32**, 633-642. DOI: +[10.1081/CSS-100103897](https://doi.org/10.1081/CSS-100103897). -ASTM D422-63 (2007). *Standard Test Method for Particle-Size Analysis of -Soils*. Technical standard. ASTM International, West Conshohocken, PA. +ASTM D422-63 (2007). *Standard Test Method for Particle-Size Analysis of Soils*. +Technical standard. ASTM International, West Conshohocken, PA. -Bouyoucos, G.J., (1927). The hydrometer as a new method for the mechanical +Bouyoucos, G.J., (1927). The hydrometer as a new method for the mechanical analysis of soils. Soil Science 23, 343–354. Moeys, J., Shangguan, W., Petzold, R., Minasny, B., Rosca, B., Jelinski, N., -Zelazny, W., Souza, R.M.S., Safanelli, J.L., & ten Caten, A. (2018). *soiltexture: -Functions for Soil Texture Plot, Classification and Transformation*. URL: [https://CRAN.R-project.org/package=soiltexture](https://CRAN.R-project.org/package=soiltexture). +Zelazny, W., Souza, R.M.S., Safanelli, J.L., & ten Caten, A. (2018). +*soiltexture: Functions for Soil Texture Plot, Classification and +Transformation*. URL: +[https://CRAN.R-project.org/package=soiltexture](https://CRAN.R-project.org/package=soiltexture). diff --git a/vignettes/texture.html b/vignettes/texture.html index 07e834e..f882ed1 100644 --- a/vignettes/texture.html +++ b/vignettes/texture.html @@ -11,9 +11,9 @@ - + -Particle size estimation using the hydrometer method modified from ASTM D422-63 (2007) and Bouyoucos (1927) +Particle size estimation with texture() - - + - + + diff --git a/vignettes/theme_publish.md b/vignettes/theme_publish.md index 23deeb5..7c01e87 100644 --- a/vignettes/theme_publish.md +++ b/vignettes/theme_publish.md @@ -1,7 +1,7 @@ --- -title: "theme_publish() demo" +title: "`theme_publish()` showcase" author: "Zacharias Steinmetz" -date: "2020-04-07" +date: "2023-09-05" output: html_document: keep_md: yes @@ -16,21 +16,33 @@ vignette: > -## Sample code +First, we require **ggplot2**. ```r -require(envalysis) -require(ggplot2) +library(envalysis) +library(ggplot2) +``` + +We use the `mtcars` sample data set for plotting with the default **ggplot2** +theme. + + +```r +data("mtcars") + p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg, - colour=factor(gear))) + facet_wrap( ~ am) + color = factor(gear))) + facet_wrap( ~ am) p ``` -![](/home/steinmetz-z/Documents/PhD/Code/envalysis/vignettes/theme_publish_files/figure-html/theme_publish-1.png) +![](/home/zacharias/Dokumente/RPTU/Seafile/Research/Code/envalysis/vignettes/theme_publish_files/figure-html/default_theme-1.png) + +Adding `theme_publish()` applies the custom theme. + ```r p + theme_publish() ``` -![](/home/steinmetz-z/Documents/PhD/Code/envalysis/vignettes/theme_publish_files/figure-html/theme_publish-2.png) +![](/home/zacharias/Dokumente/RPTU/Seafile/Research/Code/envalysis/vignettes/theme_publish_files/figure-html/theme_publish-1.png) diff --git a/vignettes/theme_publish_files/figure-html/default_theme-1.png b/vignettes/theme_publish_files/figure-html/default_theme-1.png new file mode 100644 index 0000000..2572e39 Binary files /dev/null and b/vignettes/theme_publish_files/figure-html/default_theme-1.png differ diff --git a/vignettes/theme_publish_files/figure-html/theme_publish-1.png b/vignettes/theme_publish_files/figure-html/theme_publish-1.png index f5717c5..9ed09f1 100644 Binary files a/vignettes/theme_publish_files/figure-html/theme_publish-1.png and b/vignettes/theme_publish_files/figure-html/theme_publish-1.png differ diff --git a/vignettes/theme_publish_files/figure-html/theme_publish-2.png b/vignettes/theme_publish_files/figure-html/theme_publish-2.png index 275ed51..9ed09f1 100644 Binary files a/vignettes/theme_publish_files/figure-html/theme_publish-2.png and b/vignettes/theme_publish_files/figure-html/theme_publish-2.png differ