Title: | Tools for Cleaning Rectangular Data |
---|---|
Description: | A dependency-free collection of simple functions for cleaning rectangular data. This package allows to detect, count and replace values or discard rows/columns using a predicate function. In addition, it provides tools to check conditions and return informative error messages. |
Authors: | Nicolas Frerebeau [aut, cre] (<https://orcid.org/0000-0001-5759-4944>, Université Bordeaux Montaigne), Brice Lebrun [ctb] (<https://orcid.org/0000-0001-7503-8685>, Logo designer), Université Bordeaux Montaigne [fnd], CNRS [fnd] |
Maintainer: | Nicolas Frerebeau <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.7.0 |
Built: | 2024-09-20 05:34:15 UTC |
Source: | https://github.com/tesselle/arkhe |
Convert Row Names to an Explicit Column
append_rownames(x, ...) ## S4 method for signature 'data.frame' append_rownames(x, after = 0, remove = TRUE, var = "rownames")
append_rownames(x, ...) ## S4 method for signature 'data.frame' append_rownames(x, after = 0, remove = TRUE, var = "rownames")
x |
A |
... |
Currently not used. |
after |
A length-one |
remove |
A |
var |
A |
A data.frame
.
N. Frerebeau
Other data preparation tools:
assign()
,
compact()
,
count()
,
detect()
,
discard()
,
get()
,
keep()
,
seek()
X <- data.frame( x = 1:5, y = 6:10, z = LETTERS[1:5] ) ## Assign column to row names (Y <- assign_rownames(X, 3)) ## Append row names to data.frame (Z <- append_rownames(Y))
X <- data.frame( x = 1:5, y = 6:10, z = LETTERS[1:5] ) ## Assign column to row names (Y <- assign_rownames(X, 3)) ## Append row names to data.frame (Z <- append_rownames(Y))
Check Numeric Trend
assert_constant(x, ...) assert_decreasing(x, ...) assert_increasing(x, ...)
assert_constant(x, ...) assert_decreasing(x, ...) assert_increasing(x, ...)
x |
A |
... |
Extra parameters to be passed to internal methods. |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_data
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_square()
,
assert_type()
,
validate()
assert_missing()
and assert_infinite()
check if an object contains any
missing (NA
, NaN
) or infinite (Inf
) value.
assert_unique()
checks if an object contains duplicated elements.
assert_missing(x) assert_infinite(x) assert_unique(x)
assert_missing(x) assert_infinite(x) assert_unique(x)
x |
An object to be checked. |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_square()
,
assert_type()
,
validate()
Check Object Length/Dimensions
assert_length(x, expected, empty = FALSE) assert_lengths(x, expected) assert_empty(x) assert_filled(x) assert_dimensions(x, expected)
assert_length(x, expected, empty = FALSE) assert_lengths(x, expected) assert_empty(x) assert_filled(x) assert_dimensions(x, expected)
x |
An object to be checked. |
expected |
An appropriate expected value. |
empty |
A |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_square()
,
assert_type()
,
validate()
Check Numeric Relations
assert_lower(x, y, ...) assert_greater(x, y, ...)
assert_lower(x, y, ...) assert_greater(x, y, ...)
x , y
|
A |
... |
Extra parameters to be passed to internal methods. |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_square()
,
assert_type()
,
validate()
Check Object Names
assert_names(x, expected) assert_dimnames(x, expected) assert_rownames(x, expected) assert_colnames(x, expected)
assert_names(x, expected) assert_dimnames(x, expected) assert_rownames(x, expected) assert_colnames(x, expected)
x |
An object to be checked. |
expected |
An appropriate expected value. |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_lower()
,
assert_numeric
,
assert_package()
,
assert_square()
,
assert_type()
,
validate()
Check Numeric Values
assert_count(x, na.rm = FALSE, ...) assert_whole(x, na.rm = FALSE, ...) assert_positive(x, na.rm = FALSE, ...) assert_negative(x, na.rm = FALSE, ...) assert_odd(x, na.rm = FALSE, ...) assert_even(x, na.rm = FALSE, ...)
assert_count(x, na.rm = FALSE, ...) assert_whole(x, na.rm = FALSE, ...) assert_positive(x, na.rm = FALSE, ...) assert_negative(x, na.rm = FALSE, ...) assert_odd(x, na.rm = FALSE, ...) assert_even(x, na.rm = FALSE, ...)
x |
A |
na.rm |
A |
... |
Extra parameters to be passed to internal methods. |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_package()
,
assert_square()
,
assert_type()
,
validate()
Check the Availability of a Package
assert_package(x, ask = TRUE) needs(x, ask = TRUE)
assert_package(x, ask = TRUE) needs(x, ask = TRUE)
x |
A |
ask |
A |
assert_package()
is designed for use inside other functions in your own
package to check for the availability of a suggested package.
If the required packages are not available and R is running interactively, the user will be asked to install the packages.
needs()
is an alias for assert_package()
.
Invisibly returns NULL
.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_square()
,
assert_type()
,
validate()
Check Matrix
assert_square(x) assert_symmetric(x)
assert_square(x) assert_symmetric(x)
x |
A |
Throw an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_type()
,
validate()
Check Data Types
assert_type(x, expected) assert_scalar(x, expected) assert_function(x)
assert_type(x, expected) assert_scalar(x, expected) assert_function(x)
x |
An object to be checked. |
expected |
A |
Throws an error, if any, and returns x
invisibly otherwise.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_square()
,
validate()
Assign a Specific Row/Column to the Column/Row Names
assign_colnames(x, ...) assign_rownames(x, ...) ## S4 method for signature 'data.frame' assign_rownames(x, column, remove = TRUE) ## S4 method for signature 'data.frame' assign_colnames(x, row, remove = TRUE)
assign_colnames(x, ...) assign_rownames(x, ...) ## S4 method for signature 'data.frame' assign_rownames(x, column, remove = TRUE) ## S4 method for signature 'data.frame' assign_colnames(x, row, remove = TRUE)
x |
A |
... |
Currently not used. |
column |
A length-one |
remove |
A |
row |
A length-one |
A data.frame
.
N. Frerebeau
Other data preparation tools:
append()
,
compact()
,
count()
,
detect()
,
discard()
,
get()
,
keep()
,
seek()
X <- data.frame( x = 1:5, y = 6:10, z = LETTERS[1:5] ) ## Assign column to row names (Y <- assign_rownames(X, 3)) ## Append row names to data.frame (Z <- append_rownames(Y))
X <- data.frame( x = 1:5, y = 6:10, z = LETTERS[1:5] ) ## Assign column to row names (Y <- assign_rownames(X, 3)) ## Append row names to data.frame (Z <- append_rownames(Y))
Samples randomly from the elements of object
with replacement.
bootstrap(object, ...) ## S4 method for signature 'numeric' bootstrap(object, do, n, ..., f = NULL)
bootstrap(object, ...) ## S4 method for signature 'numeric' bootstrap(object, do, n, ..., f = NULL)
object |
A |
... |
Extra arguments to be passed to |
do |
A |
n |
A non-negative |
f |
A |
If f
is NULL
(the default), bootstrap()
returns a named numeric
vector with the following elements:
original
The observed value of do
applied to object
.
mean
The bootstrap estimate of mean of do
.
bias
The bootstrap estimate of bias of do
.
error
he bootstrap estimate of standard error of do
.
If f
is a function
, bootstrap()
returns the result of f
applied to
the n
values of do
.
N. Frerebeau
Other resampling methods:
jackknife()
x <- rnorm(20) ## Bootstrap bootstrap(x, do = mean, n = 100) ## Estimate the 25th and 95th percentiles quant <- function(x) { quantile(x, probs = c(0.25, 0.75)) } bootstrap(x, n = 100, do = mean, f = quant) ## Get the n bootstrap values bootstrap(x, n = 100, do = mean, f = function(x) { x }) ## Jackknife jackknife(x, do = mean) # Sample mean ## Get the leave-one-out values instead of summary jackknife(x, do = mean, f = function(x) { x })
x <- rnorm(20) ## Bootstrap bootstrap(x, do = mean, n = 100) ## Estimate the 25th and 95th percentiles quant <- function(x) { quantile(x, probs = c(0.25, 0.75)) } bootstrap(x, n = 100, do = mean, f = quant) ## Get the n bootstrap values bootstrap(x, n = 100, do = mean, f = function(x) { x }) ## Jackknife jackknife(x, do = mean) # Sample mean ## Get the leave-one-out values instead of summary jackknife(x, do = mean, f = function(x) { x })
Remove Leading/Trailing Whitespace
clean_whitespace(x, ...) ## S4 method for signature 'data.frame' clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE) ## S4 method for signature 'matrix' clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE)
clean_whitespace(x, ...) ## S4 method for signature 'data.frame' clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE) ## S4 method for signature 'matrix' clean_whitespace(x, which = c("both", "left", "right"), squish = TRUE)
x |
An R object (should be a |
... |
Currently not used. |
which |
A |
squish |
A |
N. Frerebeau
Other data cleaning tools:
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
,
replace_zero()
x <- data.frame( A = c(" Both ", " Left", "Right "), B = 1:3 ) clean_whitespace(x, which = "both") clean_whitespace(x, which = "left") clean_whitespace(x, which = "right")
x <- data.frame( A = c(" Both ", " Left", "Right "), B = 1:3 ) clean_whitespace(x, which = "both") clean_whitespace(x, which = "left") clean_whitespace(x, which = "right")
Removes empty rows/columns in an array-like object.
compact(x, ...) compact_cols(x, ...) compact_rows(x, ...) ## S4 method for signature 'ANY' compact(x, margin = 1, na.rm = FALSE, verbose = getOption("arkhe.verbose")) ## S4 method for signature 'ANY' compact_cols(x, na.rm = FALSE, verbose = getOption("arkhe.verbose")) ## S4 method for signature 'ANY' compact_rows(x, na.rm = FALSE, verbose = getOption("arkhe.verbose"))
compact(x, ...) compact_cols(x, ...) compact_rows(x, ...) ## S4 method for signature 'ANY' compact(x, margin = 1, na.rm = FALSE, verbose = getOption("arkhe.verbose")) ## S4 method for signature 'ANY' compact_cols(x, na.rm = FALSE, verbose = getOption("arkhe.verbose")) ## S4 method for signature 'ANY' compact_rows(x, na.rm = FALSE, verbose = getOption("arkhe.verbose"))
x |
An R object (should be a |
... |
Currently not used. |
margin |
A length-one |
na.rm |
A |
verbose |
A |
A row/column is empty if it contains only zeros (if of type numeric
)
or zero length character strings (if of type character
).
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
count()
,
detect()
,
discard()
,
get()
,
keep()
,
seek()
## Create a data.frame X <- data.frame(A = 0, B = 1:5, C = 6, D = "", F = letters[1:5]) X ## Remove empty columns compact(X, margin = 2)
## Create a data.frame X <- data.frame(A = 0, B = 1:5, C = 6, D = "", F = letters[1:5]) X ## Remove empty columns compact(X, margin = 2)
Concatenates character vectors.
x %+% y
x %+% y
x , y
|
A |
A character
vector.
Other utilities:
null
Computes a Wald interval for a proportion at a desired level of significance.
confidence_binomial(object, ...) ## S4 method for signature 'numeric' confidence_binomial( object, n, level = 0.95, method = "wald", corrected = FALSE )
confidence_binomial(object, ...) ## S4 method for signature 'numeric' confidence_binomial( object, n, level = 0.95, method = "wald", corrected = FALSE )
object |
A |
... |
Currently not used. |
n |
A length-one |
level |
A length-one |
method |
A |
corrected |
A |
A length-two numeric
vector giving the lower and upper confidence
limits.
N. Frerebeau
Other summary statistics:
confidence_mean()
,
confidence_multinomial()
,
interval_credible()
,
interval_hdr()
## Confidence interval for a mean x <- seq(from = -4, to = 4, by = 0.01) y <- dnorm(x) confidence_mean(y, type = "student") confidence_mean(y, type = "normal") ## Confidence interval for a propotion confidence_binomial(118, n = 236) x <- c(35, 74, 22, 69) confidence_multinomial(x)
## Confidence interval for a mean x <- seq(from = -4, to = 4, by = 0.01) y <- dnorm(x) confidence_mean(y, type = "student") confidence_mean(y, type = "normal") ## Confidence interval for a propotion confidence_binomial(118, n = 236) x <- c(35, 74, 22, 69) confidence_multinomial(x)
Computes a confidence interval for a mean at a desired level of significance.
confidence_mean(object, ...) ## S4 method for signature 'numeric' confidence_mean(object, level = 0.95, type = c("student", "normal"))
confidence_mean(object, ...) ## S4 method for signature 'numeric' confidence_mean(object, level = 0.95, type = c("student", "normal"))
object |
A |
... |
Currently not used. |
level |
A length-one |
type |
A |
A length-two numeric
vector giving the lower and upper confidence
limits.
N. Frerebeau
Other summary statistics:
confidence_binomial()
,
confidence_multinomial()
,
interval_credible()
,
interval_hdr()
## Confidence interval for a mean x <- seq(from = -4, to = 4, by = 0.01) y <- dnorm(x) confidence_mean(y, type = "student") confidence_mean(y, type = "normal") ## Confidence interval for a propotion confidence_binomial(118, n = 236) x <- c(35, 74, 22, 69) confidence_multinomial(x)
## Confidence interval for a mean x <- seq(from = -4, to = 4, by = 0.01) y <- dnorm(x) confidence_mean(y, type = "student") confidence_mean(y, type = "normal") ## Confidence interval for a propotion confidence_binomial(118, n = 236) x <- c(35, 74, 22, 69) confidence_multinomial(x)
Computes a Wald interval for a proportion at a desired level of significance.
confidence_multinomial(object, ...) ## S4 method for signature 'numeric' confidence_multinomial( object, level = 0.95, method = "wald", corrected = FALSE )
confidence_multinomial(object, ...) ## S4 method for signature 'numeric' confidence_multinomial( object, level = 0.95, method = "wald", corrected = FALSE )
object |
A |
... |
Currently not used. |
level |
A length-one |
method |
A |
corrected |
A |
A two column numeric
matrix
giving the lower and upper
confidence limits.
N. Frerebeau
Other summary statistics:
confidence_binomial()
,
confidence_mean()
,
interval_credible()
,
interval_hdr()
## Confidence interval for a mean x <- seq(from = -4, to = 4, by = 0.01) y <- dnorm(x) confidence_mean(y, type = "student") confidence_mean(y, type = "normal") ## Confidence interval for a propotion confidence_binomial(118, n = 236) x <- c(35, 74, 22, 69) confidence_multinomial(x)
## Confidence interval for a mean x <- seq(from = -4, to = 4, by = 0.01) y <- dnorm(x) confidence_mean(y, type = "student") confidence_mean(y, type = "normal") ## Confidence interval for a propotion confidence_binomial(118, n = 236) x <- c(35, 74, 22, 69) confidence_multinomial(x)
Counts values by rows/columns using a predicate function.
count(x, ...) ## S4 method for signature 'data.frame' count(x, f, margin = 1, negate = FALSE, na.rm = FALSE, ...) ## S4 method for signature 'matrix' count(x, f, margin = 1, negate = FALSE, na.rm = FALSE, ...)
count(x, ...) ## S4 method for signature 'data.frame' count(x, f, margin = 1, negate = FALSE, na.rm = FALSE, ...) ## S4 method for signature 'matrix' count(x, f, margin = 1, negate = FALSE, na.rm = FALSE, ...)
x |
An R object (should be a |
... |
Further arguments to be passed to |
f |
A predicate |
margin |
A length-one |
negate |
A |
na.rm |
A |
A numeric
vector.
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
compact()
,
detect()
,
discard()
,
get()
,
keep()
,
seek()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Count missing values in rows count(X, f = is.na, margin = 1) ## Count non-missing values in columns count(X, f = is.na, margin = 2, negate = TRUE)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Count missing values in rows count(X, f = is.na, margin = 1) ## Count non-missing values in columns count(X, f = is.na, margin = 2, negate = TRUE)
Describes an object.
describe(x, ...) ## S4 method for signature 'ANY' describe(x)
describe(x, ...) ## S4 method for signature 'ANY' describe(x)
x |
An R object (should be a |
... |
Currently not used. |
describe()
is called for its side-effects. Invisibly returns x
.
N. Frerebeau
Other data summaries:
sparsity()
## Create a data matrix X <- matrix(sample(0:9, 15, TRUE), nrow = 3, ncol = 5) ## Add NA k <- sample(1:15, 3, FALSE) X[k] <- NA ## Sparsity sparsity(X) ## Quick description describe(X)
## Create a data matrix X <- matrix(sample(0:9, 15, TRUE), nrow = 3, ncol = 5) ## Add NA k <- sample(1:15, 3, FALSE) X[k] <- NA ## Sparsity sparsity(X) ## Quick description describe(X)
Finds rows/columns in an array-like object using a predicate function.
detect(x, ...) ## S4 method for signature 'ANY' detect(x, f, margin = 1, negate = FALSE, all = FALSE, na.rm = FALSE, ...)
detect(x, ...) ## S4 method for signature 'ANY' detect(x, f, margin = 1, negate = FALSE, all = FALSE, na.rm = FALSE, ...)
x |
An R object (should be a |
... |
Further arguments to be passed to |
f |
A predicate |
margin |
A length-one |
negate |
A |
all |
A |
na.rm |
A |
A logical
vector.
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
compact()
,
count()
,
discard()
,
get()
,
keep()
,
seek()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Find row with NA detect(X, f = is.na, margin = 1) ## Find column without any NA detect(X, f = is.na, margin = 2, negate = TRUE, all = TRUE)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Find row with NA detect(X, f = is.na, margin = 1) ## Find column without any NA detect(X, f = is.na, margin = 2, negate = TRUE, all = TRUE)
Removes rows/columns in an array-like object using a predicate function.
discard(x, ...) discard_cols(x, ...) discard_rows(x, ...) ## S4 method for signature 'ANY' discard( x, f, margin = 1, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' discard_rows( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' discard_cols( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... )
discard(x, ...) discard_cols(x, ...) discard_rows(x, ...) ## S4 method for signature 'ANY' discard( x, f, margin = 1, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' discard_rows( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' discard_cols( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... )
x |
An R object (should be a |
... |
Further arguments to be passed to |
f |
A predicate |
margin |
A length-one |
negate |
A |
all |
A |
na.rm |
A |
verbose |
A |
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
compact()
,
count()
,
detect()
,
get()
,
keep()
,
seek()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Remove row with any NA discard(X, f = is.na, margin = 1, all = FALSE) ## Remove column with any NA discard(X, f = is.na, margin = 2, all = FALSE)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Remove row with any NA discard(X, f = is.na, margin = 1, all = FALSE) ## Remove column with any NA discard(X, f = is.na, margin = 2, all = FALSE)
Returns rows/columns selected by name in an array-like object.
get_columns(x, ...) get_rows(x, ...) ## S4 method for signature 'data.frame' get_columns(x, select = NULL, ...) ## S4 method for signature 'data.frame' get_rows(x, select = NULL, ...)
get_columns(x, ...) get_rows(x, ...) ## S4 method for signature 'data.frame' get_columns(x, select = NULL, ...) ## S4 method for signature 'data.frame' get_rows(x, select = NULL, ...)
x |
An R object (should be a |
... |
Further arguments to be passed to |
select |
A |
An object of the same sort as x
.
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
compact()
,
count()
,
detect()
,
discard()
,
keep()
,
seek()
## Seek columns seek_columns(iris, select = startsWith, prefix = "Sepal") ## Get columns x <- get_columns(iris, select = startsWith, prefix = "Sepal") head(x)
## Seek columns seek_columns(iris, select = startsWith, prefix = "Sepal") ## Get columns x <- get_columns(iris, select = startsWith, prefix = "Sepal") head(x)
Computes the shortest credible interval within which an unobserved parameter value falls with a particular probability.
interval_credible(x, ...) ## S4 method for signature 'numeric' interval_credible(x, level = 0.95)
interval_credible(x, ...) ## S4 method for signature 'numeric' interval_credible(x, level = 0.95)
x |
A |
... |
Currently not used. |
level |
A length-one |
A three-columns numeric
matrix
giving the lower and upper boundaries
of the credible interval and associated probability.
N. Frerebeau
Other summary statistics:
confidence_binomial()
,
confidence_mean()
,
confidence_multinomial()
,
interval_hdr()
## HDR of the Old Faithful eruption times interval_hdr(faithful$eruptions)
## HDR of the Old Faithful eruption times interval_hdr(faithful$eruptions)
Highest Density Regions
interval_hdr(x, y, ...) ## S4 method for signature 'numeric,numeric' interval_hdr(x, y, level = 0.954) ## S4 method for signature 'numeric,missing' interval_hdr(x, level = 0.954, ...)
interval_hdr(x, y, ...) ## S4 method for signature 'numeric,numeric' interval_hdr(x, y, level = 0.954) ## S4 method for signature 'numeric,missing' interval_hdr(x, level = 0.954, ...)
x |
A |
y |
A |
... |
Further arguments to be passed to |
level |
A length-one |
A three-columns numeric
matrix
giving the lower and upper boundaries
of the HPD interval and associated probabilities.
N. Frerebeau
Hyndman, R. J. (1996). Computing and graphing highest density regions. American Statistician, 50: 120-126. doi:10.2307/2684423.
Other summary statistics:
confidence_binomial()
,
confidence_mean()
,
confidence_multinomial()
,
interval_credible()
## HDR of the Old Faithful eruption times interval_hdr(faithful$eruptions)
## HDR of the Old Faithful eruption times interval_hdr(faithful$eruptions)
Scalar Type Predicates
is_scalar_list(x) is_scalar_atomic(x) is_scalar_vector(x) is_scalar_numeric(x) is_scalar_integer(x) is_scalar_double(x) is_scalar_character(x) is_scalar_logical(x)
is_scalar_list(x) is_scalar_atomic(x) is_scalar_vector(x) is_scalar_numeric(x) is_scalar_integer(x) is_scalar_double(x) is_scalar_character(x) is_scalar_logical(x)
x |
An object to be tested. |
A logical
scalar.
Other predicates:
predicate-matrix
,
predicate-numeric
,
predicate-trend
,
predicate-type
,
predicate-utils
Jackknife Estimation
jackknife(object, ...) ## S4 method for signature 'numeric' jackknife(object, do, ..., f = NULL)
jackknife(object, ...) ## S4 method for signature 'numeric' jackknife(object, do, ..., f = NULL)
object |
A |
... |
Extra arguments to be passed to |
do |
A |
f |
A |
If f
is NULL
(the default), jackknife()
returns a named numeric
vector with the following elements:
original
The observed value of do
applied to object
.
mean
The jackknife estimate of mean of do
.
bias
The jackknife estimate of bias of do
.
error
he jackknife estimate of standard error of do
.
If f
is a function
, jackknife()
returns the result of f
applied to
the leave-one-out values of do
.
N. Frerebeau
Other resampling methods:
bootstrap()
x <- rnorm(20) ## Bootstrap bootstrap(x, do = mean, n = 100) ## Estimate the 25th and 95th percentiles quant <- function(x) { quantile(x, probs = c(0.25, 0.75)) } bootstrap(x, n = 100, do = mean, f = quant) ## Get the n bootstrap values bootstrap(x, n = 100, do = mean, f = function(x) { x }) ## Jackknife jackknife(x, do = mean) # Sample mean ## Get the leave-one-out values instead of summary jackknife(x, do = mean, f = function(x) { x })
x <- rnorm(20) ## Bootstrap bootstrap(x, do = mean, n = 100) ## Estimate the 25th and 95th percentiles quant <- function(x) { quantile(x, probs = c(0.25, 0.75)) } bootstrap(x, n = 100, do = mean, f = quant) ## Get the n bootstrap values bootstrap(x, n = 100, do = mean, f = function(x) { x }) ## Jackknife jackknife(x, do = mean) # Sample mean ## Get the leave-one-out values instead of summary jackknife(x, do = mean, f = function(x) { x })
Keeps rows/columns in an array-like object using a predicate function.
keep(x, ...) keep_cols(x, ...) keep_rows(x, ...) ## S4 method for signature 'ANY' keep( x, f, margin = 1, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' keep_rows( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' keep_cols( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... )
keep(x, ...) keep_cols(x, ...) keep_rows(x, ...) ## S4 method for signature 'ANY' keep( x, f, margin = 1, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' keep_rows( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... ) ## S4 method for signature 'ANY' keep_cols( x, f, negate = FALSE, all = FALSE, na.rm = FALSE, verbose = getOption("arkhe.verbose"), ... )
x |
An R object (should be a |
... |
Further arguments to be passed to |
f |
A predicate |
margin |
A length-one |
negate |
A |
all |
A |
na.rm |
A |
verbose |
A |
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
compact()
,
count()
,
detect()
,
discard()
,
get()
,
seek()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Keep row without any NA keep(X, f = is.na, margin = 1, negate = TRUE, all = TRUE) ## Keep row without any NA keep(X, f = is.na, margin = 2, negate = TRUE, all = TRUE)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Keep row without any NA keep(X, f = is.na, margin = 1, negate = TRUE, all = TRUE) ## Keep row without any NA keep(X, f = is.na, margin = 2, negate = TRUE, all = TRUE)
Computes the greatest common divisor (GCD) of two integer using the Euclidean algorithm.
math_gcd(x, y) ## S4 method for signature 'numeric,numeric' math_gcd(x, y)
math_gcd(x, y) ## S4 method for signature 'numeric,numeric' math_gcd(x, y)
x , y
|
A |
A numeric
vector.
N. Frerebeau
Other mathematic functions:
math_lcm()
Computes the lowest common multiple of the denominators of a set of fractions.
math_lcm(x, y) ## S4 method for signature 'numeric,numeric' math_lcm(x, y)
math_lcm(x, y) ## S4 method for signature 'numeric,numeric' math_lcm(x, y)
x , y
|
A |
A numeric
vector.
N. Frerebeau
Other mathematic functions:
math_gcd()
Replaces NULL
with a default value.
x %||% y
x %||% y
x , y
|
An object. |
If x
is NULL
, returns y
; otherwise returns x
.
Other utilities:
concat
is_square()
checks if a matrix is square.
is_symmetric()
checks if a matrix is symmetric.
is_square(x) is_symmetric(x)
is_square(x) is_symmetric(x)
x |
A |
A logical
scalar.
Other predicates:
is_scalar
,
predicate-numeric
,
predicate-trend
,
predicate-type
,
predicate-utils
Check numeric objects:
is_zero()
checks if an object contains only zeros.
is_odd()
and is_even()
check if a number is odd or even, respectively.
is_positive()
and is_negative
check if an object contains only
(strictly) positive or negative numbers.
is_whole()
checks if an object only contains whole numbers.
is_zero(x, tolerance = sqrt(.Machine$double.eps), ...) is_odd(x, ...) is_even(x, ...) is_positive(x, strict = FALSE, ...) is_negative(x, strict = FALSE, ...) is_whole(x, tolerance = sqrt(.Machine$double.eps), ...)
is_zero(x, tolerance = sqrt(.Machine$double.eps), ...) is_odd(x, ...) is_even(x, ...) is_positive(x, strict = FALSE, ...) is_negative(x, strict = FALSE, ...) is_whole(x, tolerance = sqrt(.Machine$double.eps), ...)
x |
A |
tolerance |
A |
... |
Currently not used. |
strict |
A |
A logical
vector.
Other predicates:
is_scalar
,
predicate-matrix
,
predicate-trend
,
predicate-type
,
predicate-utils
Check numeric objects:
is_constant()
checks for equality among all elements of a vector.
is_increasing()
and is_decreasing()
check if a sequence of numbers
is monotonically increasing or decreasing, respectively.
is_constant(x, tolerance = sqrt(.Machine$double.eps), na.rm = FALSE) is_increasing(x, na.rm = FALSE) is_decreasing(x, na.rm = FALSE) is_greater(x, y, strict = FALSE, na.rm = FALSE) is_lower(x, y, strict = FALSE, na.rm = FALSE)
is_constant(x, tolerance = sqrt(.Machine$double.eps), na.rm = FALSE) is_increasing(x, na.rm = FALSE) is_decreasing(x, na.rm = FALSE) is_greater(x, y, strict = FALSE, na.rm = FALSE) is_lower(x, y, strict = FALSE, na.rm = FALSE)
x , y
|
A |
tolerance |
A |
na.rm |
A |
strict |
A |
A logical
scalar.
Other predicates:
is_scalar
,
predicate-matrix
,
predicate-numeric
,
predicate-type
,
predicate-utils
Type Predicates
is_list(x) is_atomic(x) is_vector(x) is_numeric(x) is_integer(x) is_double(x) is_character(x) is_logical(x) is_error(x) is_warning(x) is_message(x)
is_list(x) is_atomic(x) is_vector(x) is_numeric(x) is_integer(x) is_double(x) is_character(x) is_logical(x) is_error(x) is_warning(x) is_message(x)
x |
An object to be tested. |
A logical
scalar.
Other predicates:
is_scalar
,
predicate-matrix
,
predicate-numeric
,
predicate-trend
,
predicate-utils
is_empty()
checks is an object is empty (any zero-length dimensions).
has_length()
checks how long is an object.
has_names()
checks if an object is named.
has_duplicates()
checks if an object has duplicated elements.
has_missing()
and has_infinite()
check if an object contains missing
or infinite values.
has_length(x, n = NULL) is_empty(x) has_names(x, names = NULL) has_missing(x) has_infinite(x) is_unique(x, tolerance = sqrt(.Machine$double.eps), na.rm = FALSE) has_duplicates(x)
has_length(x, n = NULL) is_empty(x) has_names(x, names = NULL) has_missing(x) has_infinite(x) is_unique(x, tolerance = sqrt(.Machine$double.eps), na.rm = FALSE) has_duplicates(x)
x |
A |
n |
A length-one |
names |
A |
tolerance |
A |
na.rm |
A |
A logical
scalar.
Other predicates:
is_scalar
,
predicate-matrix
,
predicate-numeric
,
predicate-trend
,
predicate-type
Remove Constant Columns
remove_constant(x, ...) ## S4 method for signature 'ANY' remove_constant(x, na.rm = FALSE, verbose = getOption("arkhe.verbose"))
remove_constant(x, ...) ## S4 method for signature 'ANY' remove_constant(x, na.rm = FALSE, verbose = getOption("arkhe.verbose"))
x |
An R object (should be a |
... |
Currently not used. |
na.rm |
A |
verbose |
A |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
,
replace_zero()
## Create a data.frame X <- data.frame(A = 1, B = 1:3) X remove_constant(X) ## Add NA X[1, 1] <- NA remove_constant(X) remove_constant(X, na.rm = TRUE)
## Create a data.frame X <- data.frame(A = 1, B = 1:3) X remove_constant(X) ## Add NA X[1, 1] <- NA remove_constant(X) remove_constant(X, na.rm = TRUE)
Removes rows/columns that contain empty strings.
remove_empty(x, ...) ## S4 method for signature 'ANY' remove_empty(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
remove_empty(x, ...) ## S4 method for signature 'ANY' remove_empty(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
x |
An R object (should be a |
... |
Currently not used. |
margin |
A length-one |
all |
A |
verbose |
A |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
,
replace_zero()
## Create a data matrix X <- matrix(sample(LETTERS, 25, TRUE), nrow = 5, ncol = 5) ## Add empty string k <- sample(1:25, 3, FALSE) X[k] <- "" X ## Remove rows with empty strings remove_empty(X, margin = 1) ## Replace empty strings replace_empty(X, value = "XXX")
## Create a data matrix X <- matrix(sample(LETTERS, 25, TRUE), nrow = 5, ncol = 5) ## Add empty string k <- sample(1:25, 3, FALSE) X[k] <- "" X ## Remove rows with empty strings remove_empty(X, margin = 1) ## Replace empty strings replace_empty(X, value = "XXX")
Removes rows/columns that contain infinite values.
remove_Inf(x, ...) ## S4 method for signature 'ANY' remove_Inf(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
remove_Inf(x, ...) ## S4 method for signature 'ANY' remove_Inf(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
x |
An R object (should be a |
... |
Currently not used. |
margin |
A length-one |
all |
A |
verbose |
A |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
,
replace_zero()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add Inf k <- sample(1:25, 3, FALSE) X[k] <- Inf X ## Remove rows with Inf remove_Inf(X, margin = 1) ## Replace Inf with zeros replace_Inf(X, value = 0)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add Inf k <- sample(1:25, 3, FALSE) X[k] <- Inf X ## Remove rows with Inf remove_Inf(X, margin = 1) ## Replace Inf with zeros replace_Inf(X, value = 0)
Removes rows/columns that contain missing values.
remove_NA(x, ...) ## S4 method for signature 'ANY' remove_NA(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
remove_NA(x, ...) ## S4 method for signature 'ANY' remove_NA(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
x |
An R object (should be a |
... |
Currently not used. |
margin |
A length-one |
all |
A |
verbose |
A |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
,
replace_zero()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Remove rows with NA remove_NA(X, margin = 1) ## Replace NA with zeros replace_NA(X, value = 0)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Remove rows with NA remove_NA(X, margin = 1) ## Replace NA with zeros replace_NA(X, value = 0)
Removes rows/columns that contain zeros.
remove_zero(x, ...) ## S4 method for signature 'ANY' remove_zero(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
remove_zero(x, ...) ## S4 method for signature 'ANY' remove_zero(x, margin = 1, all = FALSE, verbose = getOption("arkhe.verbose"))
x |
An R object (should be a |
... |
Currently not used. |
margin |
A length-one |
all |
A |
verbose |
A |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
,
replace_zero()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add zero k <- sample(1:25, 3, FALSE) X[k] <- 0 X ## Remove rows with zero remove_zero(X, margin = 1) ## Replace zero replace_zero(X, value = 1)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add zero k <- sample(1:25, 3, FALSE) X[k] <- 0 X ## Remove rows with zero remove_zero(X, margin = 1) ## Replace zero replace_zero(X, value = 1)
Replaces empty strings.
replace_empty(x, ...) ## S4 method for signature 'matrix' replace_empty(x, value) ## S4 method for signature 'data.frame' replace_empty(x, value)
replace_empty(x, ...) ## S4 method for signature 'matrix' replace_empty(x, value) ## S4 method for signature 'data.frame' replace_empty(x, value)
x |
An R object (should be a |
... |
Currently not used. |
value |
A possible replacement value. |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_zero()
## Create a data matrix X <- matrix(sample(LETTERS, 25, TRUE), nrow = 5, ncol = 5) ## Add empty string k <- sample(1:25, 3, FALSE) X[k] <- "" X ## Remove rows with empty strings remove_empty(X, margin = 1) ## Replace empty strings replace_empty(X, value = "XXX")
## Create a data matrix X <- matrix(sample(LETTERS, 25, TRUE), nrow = 5, ncol = 5) ## Add empty string k <- sample(1:25, 3, FALSE) X[k] <- "" X ## Remove rows with empty strings remove_empty(X, margin = 1) ## Replace empty strings replace_empty(X, value = "XXX")
Replaces infinite values values.
replace_Inf(x, ...) ## S4 method for signature 'matrix' replace_Inf(x, value = 0) ## S4 method for signature 'data.frame' replace_Inf(x, value = 0)
replace_Inf(x, ...) ## S4 method for signature 'matrix' replace_Inf(x, value = 0) ## S4 method for signature 'data.frame' replace_Inf(x, value = 0)
x |
An R object (should be a |
... |
Currently not used. |
value |
A possible replacement value. |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_NA()
,
replace_empty()
,
replace_zero()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add Inf k <- sample(1:25, 3, FALSE) X[k] <- Inf X ## Remove rows with Inf remove_Inf(X, margin = 1) ## Replace Inf with zeros replace_Inf(X, value = 0)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add Inf k <- sample(1:25, 3, FALSE) X[k] <- Inf X ## Remove rows with Inf remove_Inf(X, margin = 1) ## Replace Inf with zeros replace_Inf(X, value = 0)
Replaces missing values values.
replace_NA(x, ...) ## S4 method for signature 'matrix' replace_NA(x, value = 0) ## S4 method for signature 'data.frame' replace_NA(x, value = 0)
replace_NA(x, ...) ## S4 method for signature 'matrix' replace_NA(x, value = 0) ## S4 method for signature 'data.frame' replace_NA(x, value = 0)
x |
An R object (should be a |
... |
Currently not used. |
value |
A possible replacement value. |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_empty()
,
replace_zero()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Remove rows with NA remove_NA(X, margin = 1) ## Replace NA with zeros replace_NA(X, value = 0)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add NA k <- sample(1:25, 3, FALSE) X[k] <- NA X ## Remove rows with NA remove_NA(X, margin = 1) ## Replace NA with zeros replace_NA(X, value = 0)
Replaces zeros.
replace_zero(x, ...) ## S4 method for signature 'matrix' replace_zero(x, value) ## S4 method for signature 'data.frame' replace_zero(x, value)
replace_zero(x, ...) ## S4 method for signature 'matrix' replace_zero(x, value) ## S4 method for signature 'data.frame' replace_zero(x, value)
x |
An R object (should be a |
... |
Currently not used. |
value |
A possible replacement value. |
N. Frerebeau
Other data cleaning tools:
clean_whitespace()
,
remove_Inf()
,
remove_NA()
,
remove_constant()
,
remove_empty()
,
remove_zero()
,
replace_Inf()
,
replace_NA()
,
replace_empty()
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add zero k <- sample(1:25, 3, FALSE) X[k] <- 0 X ## Remove rows with zero remove_zero(X, margin = 1) ## Replace zero replace_zero(X, value = 1)
## Create a data matrix X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5) ## Add zero k <- sample(1:25, 3, FALSE) X[k] <- 0 X ## Remove rows with zero remove_zero(X, margin = 1) ## Replace zero replace_zero(X, value = 1)
Rescales continuous vector to have specified minimum, midpoint and maximum.
scale_midpoint(x, to = c(0, 1), from = range(x, finite = TRUE), midpoint = 0)
scale_midpoint(x, to = c(0, 1), from = range(x, finite = TRUE), midpoint = 0)
x |
A |
to |
A length-two |
from |
A length-two |
midpoint |
A length-one |
A numeric
vector.
For internal use only.
Other scales:
scale_range()
Rescales continuous vector to have specified minimum and maximum.
scale_range(x, to = c(0, 1), from = range(x, finite = TRUE))
scale_range(x, to = c(0, 1), from = range(x, finite = TRUE))
x |
A |
to |
A length-two |
from |
A length-two |
A numeric
vector.
For internal use only.
Other scales:
scale_midpoint()
Searches rows/columns by name in an array-like object.
seek_columns(x, ...) seek_rows(x, ...) ## S4 method for signature 'data.frame' seek_rows(x, select = NULL, ...) ## S4 method for signature 'data.frame' seek_columns(x, select = NULL, ...)
seek_columns(x, ...) seek_rows(x, ...) ## S4 method for signature 'data.frame' seek_rows(x, select = NULL, ...) ## S4 method for signature 'data.frame' seek_columns(x, select = NULL, ...)
x |
An R object (should be a |
... |
Further arguments to be passed to |
select |
A |
An integer
vector or NULL
.
N. Frerebeau
Other data preparation tools:
append()
,
assign()
,
compact()
,
count()
,
detect()
,
discard()
,
get()
,
keep()
## Seek columns seek_columns(iris, select = startsWith, prefix = "Sepal") ## Get columns x <- get_columns(iris, select = startsWith, prefix = "Sepal") head(x)
## Seek columns seek_columns(iris, select = startsWith, prefix = "Sepal") ## Get columns x <- get_columns(iris, select = startsWith, prefix = "Sepal") head(x)
Computes data sparsity (proportion of zeros).
sparsity(x, ...) ## S4 method for signature 'matrix' sparsity(x, count = FALSE) ## S4 method for signature 'data.frame' sparsity(x, count = FALSE)
sparsity(x, ...) ## S4 method for signature 'matrix' sparsity(x, count = FALSE) ## S4 method for signature 'data.frame' sparsity(x, count = FALSE)
x |
An R object (should be a |
... |
Currently not used. |
count |
A |
If x
is a data.frame
, sparsity is computed on numeric
variables only.
A length-one numeric
vector.
N. Frerebeau
Other data summaries:
describe()
## Create a data matrix X <- matrix(sample(0:9, 15, TRUE), nrow = 3, ncol = 5) ## Add NA k <- sample(1:15, 3, FALSE) X[k] <- NA ## Sparsity sparsity(X) ## Quick description describe(X)
## Create a data matrix X <- matrix(sample(0:9, 15, TRUE), nrow = 3, ncol = 5) ## Add NA k <- sample(1:15, 3, FALSE) X[k] <- NA ## Sparsity sparsity(X) ## Quick description describe(X)
Validate a Condition
validate(expr)
validate(expr)
expr |
An object to be evaluated. |
Returns NULL
on success, otherwise returns the error as a string.
N. Frerebeau
Other validation methods:
assert_constant()
,
assert_data
,
assert_length()
,
assert_lower()
,
assert_names()
,
assert_numeric
,
assert_package()
,
assert_square()
,
assert_type()