Package 'soilReports'

Title: R Markdown Reports and Convenience Functions for Soil Survey
Description: R package container and convenience functions for soil data summary, comparison, and evaluation reports used mainly by NRCS staff.
Authors: USDA-NRCS Soil Survey Staff
Maintainer: Dylan Beaudette <[email protected]>
License: GPL (>= 3)
Version: 0.9.1
Built: 2025-03-07 01:21:54 UTC
Source: https://github.com/ncss-tech/soilReports

Help Index


Soil Reports: R-Markdown reports and convenience functions for soil survey.

Description

R package container and convenience functions for soil data summary, comparison, and evaluation reports used mainly by USDA-NRCS staff.

Instructions and project homepage.

Author(s)

Dylan E. Beaudette <[email protected]>

Examples

## Not run: 
# load this library
library(soilReports)

# list reports in the package
listReports()

# install required packages for a named report
reportSetup(reportName='southwest/mu-comparison')

# copy default configuration file and report to 'MU-comparison' in current working directory
reportInit(reportName='southwest/mu-comparison', outputDir='MU-comparison', overwrite=FALSE)

## End(Not run)

Add lines below the YAML header

Description

Add lines below the YAML header

Usage

appendBelowYAML(filepath, what)

Arguments

filepath

file path

what

character vector ines to add

Value

logical; TRUE if successful


Use cLHS to subset a data.frame using selected variables

Description

Use cLHS to subset a data.frame using selected variables

Usage

cLHS_subset(i, n, non.id.vars)

Arguments

i

a data.frame

n

number of cLHS samples (rows) to draw

non.id.vars

variables that are non-ID columns

Value

a subset data.frame corresponding to selected cLHS samples (rows)


Copy a file from source to output directory

Description

Copy a file from source to output directory

Usage

copyPath(fname, srcDir, outputDir, overwrite = FALSE)

Arguments

fname

file name

srcDir

source directory

outputDir

output directory

overwrite

overwrite? default: FALSE

Value

logical; result of file.copy


Title

Description

Title

Usage

custom.bwplot(x, coef = NA, do.out = FALSE)

Arguments

x

vector of values to summarize

coef

Moran's I associated with the current raster

do.out

not used

Value

a list containing elements: stats, n, conf, and out


Define a parameter in a code chunk

Description

Define a parameter in a code chunk

Usage

defineInCodeChunk(filepath, param.name, param.value)

Arguments

filepath

File to add code chunk to

param.name

Parameter name

param.value

Parameter value

Value

logical; TRUE if successful


Define a parameter in the YAML header

Description

Define a parameter in the YAML header

Usage

defineInYAMLHeader(filepath, param.name, param.value)

Arguments

filepath

File to add code chunk to

param.name

Parameter name

param.value

Parameter value

Value

logical; TRUE if successful


Return variables with sufficient variation for cLHS

Description

Datasets that are nearly or completely invariant can pose issues for the cLHS algorithm. This function identifies vairables that have standard deviation smaller than a specified tolerance. Default: 1e-5

Usage

findSafeVars(x, id, tol = 1e-05)

Arguments

x

data.frame in wide format

id

vector of IDs variables to exclude from SD test, first element is the group ID

tol

tolerance for near-0 SD test; Default: 1e-5

Value

A character vector of "safe" column names


Install USDA-NRCS SPSD CCE user .Rprofile

Description

Install USDA-NRCS SPSD CCE user .Rprofile

Usage

installRprofile(overwrite = FALSE, user_folder = NULL, home_drive = NULL)

Arguments

overwrite

overwrite? Default FALSE

user_folder

User folder name (default NULL; if not null used instead of file.path('C:/Users', Sys.getenv('USERNAME'), 'Documents'))

home_drive

Custom Home Drive (default NULL; if not null replaces "C:")

Value

source() a new .Rprofile set up to redirect R library paths


Calculate kernel density contour lines at specified probability levels Calculate kernel density contour lines at specified probability levels with MASS:kde2d and display with graphics::contour

Description

Calculate kernel density contour lines at specified probability levels Calculate kernel density contour lines at specified probability levels with MASS:kde2d and display with graphics::contour

Usage

kdeContours(i, id, prob, cols, m, ...)

Arguments

i

a data.frame containing unique ID, x, y

id

a unique ID column name

prob

a vector of probability levels

cols

a vector of colors

m

unique levels of the ID column (used to match colors)

...

additional arguments to graphics::contour

Value

estimated kernel density contours


List names of available reports

Description

List names of available reports

Usage

listReports(showFullPaths = FALSE)

Arguments

showFullPaths

Show full paths to files? Default: FALSE

Value

a data.frame containing report names, versions and descriptions for reports available in the currently installed version of the soilReports package.

Examples

listReports()

listReports(showFullPaths = TRUE)

Indexing for Plotting and Printing

Description

This function creates an index to iterate over when plotting or printing large objects.

Usage

pIndex(x, interval = 4)

Arguments

x

a data.frame, SoilProfileCollection or table

interval

a value specifying the interval length desired; Default: 4

Value

a numeric vector

Examples

x <- as.data.frame(matrix(1:100, ncol = 10))
pIndex(x, interval = 3)

Pretty Quantile Printing

Description

This function generates a pretty quantile summary for printing.

Usage

prettySummary(x, p = c(0, 0.25, 0.5, 0.75, 1), n = TRUE, signif = TRUE)

Arguments

x

a numeric vector

p

a numeric vector of percentiles

n

a logical value indicating whether the vector of percentiles should be appended with the number of observations

signif

a logical value indicating whether the percentiles should be rounded to the precision of the data

Value

a character value of quantiles and optionally the number of observations

Author(s)

Stephen Roecker

Examples

x <- 1.1:10.1
prettySummary(x)

Copy default configuration file and report contents to new directory

Description

reportInit allows creation new report instances, or updates, from the soilReports R package. soilReports is a container for reports and convenience functions for soil data summary, comparison, and evaluation reports used mainly by USDA-NRCS staff.

Usage

reportInit(
  reportName,
  outputDir = NULL,
  overwrite = FALSE,
  updateReport = FALSE
)

Arguments

reportName

Name of report, as found in listReports. Format: directory/reportName.

outputDir

Directory to create report instance

overwrite

Overwrite existing directories and files? Default FALSE

updateReport

Only update core report files, leaving configuration unchanged? Specific settings are report-dependent and set in the setup.R manifest.

Value

A time-stamped report instance created in outputDir, and a message summarizing the action(s) completed.


Install packages needed for a report

Description

Install packages needed for a report

Usage

reportSetup(reportName, upgrade = TRUE)

Arguments

reportName

Name of report, as found in listReports. Format: directory/reportName.

upgrade

Upgrade CRAN packages? Default: TRUE

Value

Installed packages from CRAN and GitHub in user library, as specified in report-specific manifest.


Compute scaled density for a data.frame containing "value"

Description

Gaussian probability densities are re-scaled to ⁠[0,1]⁠

Usage

scaled.density(d, constantScaling = TRUE)

Arguments

d

data.frame containing column "value"

constantScaling

use scales::rescale? Default: TRUE

Value

A data.frame containing (scaled) x and y