Learn R Programming

⚠️There's a newer version (1.10.0) of this package.Take me there.

arkhe

Overview

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.

Installation

You can install the released version of arkhe from CRAN with:

install.packages("arkhe")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("tesselle/arkhe")

Usage

## Load the package
library(arkhe)

## Create a matrix
X <- matrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5)

## Add NA
k <- sample(1:25, 3, FALSE)
X[k] <- NA
X
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    2    5   NA    6   NA
#> [2,]    4    1    5    2    5
#> [3,]    2    6   NA    6   10
#> [4,]    1    7    6    5    6
#> [5,]    6    1    8    8    6

## Count missing values in rows
count(X, f = is.na, margin = 1)
#> [1] 2 0 1 0 0
## Count non-missing values in columns
count(X, f = is.na, margin = 2, negate = TRUE)
#> [1] 5 5 3 5 4

## Find row with NA
detect(X, f = is.na, margin = 1)
#> [1]  TRUE FALSE  TRUE FALSE FALSE
## Find column without any NA
detect(X, f = is.na, margin = 2, negate = TRUE, all = TRUE)
#> [1]  TRUE  TRUE FALSE  TRUE FALSE

## Remove row with any NA
discard(X, f = is.na, margin = 1, all = FALSE)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    4    1    5    2    5
#> [2,]    1    7    6    5    6
#> [3,]    6    1    8    8    6
## Remove column with any NA
discard(X, f = is.na, margin = 2, all = FALSE)
#>      [,1] [,2] [,3]
#> [1,]    2    5    6
#> [2,]    4    1    2
#> [3,]    2    6    6
#> [4,]    1    7    5
#> [5,]    6    1    8

## Replace NA with zeros
replace_NA(X, value = 0)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    2    5    0    6    0
#> [2,]    4    1    5    2    5
#> [3,]    2    6    0    6   10
#> [4,]    1    7    6    5    6
#> [5,]    6    1    8    8    6

Contributing

Please note that the arkhe project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('arkhe')

Monthly Downloads

1,015

Version

1.2.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Frerebeau

Last Published

May 11th, 2023

Functions in arkhe (1.2.0)

detect

Find rows/columns using a predicate
deprecate

Deprecated Methods
confidence_binomial

Confidence Interval for Binomial Proportions
confidence_multinomial

Confidence Interval for Multinomial Proportions
check-type

Check Data Types
check_class

Class Diagnostic
confidence_mean

Confidence Interval for a Mean
count

Count values using a predicate
compact

Remove empty rows/columns
jackknife

Jackknife Estimation
math_lcm

Least Common Multiple
math_gcd

Greatest Common Divisor
conditions

Conditions
discard

Remove rows/columns using a predicate
infinite

Tools for working with infinite values
predicate-numeric

Numeric Predicates
zero

Tools for working with zeros
needs

Check the Availability of a Package
predicate-matrix

Matrix Predicates
keep

Keep rows/columns using a predicate
with_seed

Evaluate an Expression with a Temporarily Seed
missing

Tools for working with missing values
interval_credible

Bayesian Credible Interval
predicate-scalar

Scalar Type Predicates
interval_hdr

Highest Density Regions
reshape

Reshape
predicate-trend

Numeric Trend Predicates
predicate-type

Type Predicates
validate

Validate a Condition
predicate-utils

Utility Predicates
check-attribute

Check Object Attributes
check-data

Check Data
arkhe-package

arkhe: Tools for Cleaning Rectangular Data
assign

Assign a specific row/column to the column/row names
append

Convert row names to an explicit column
bootstrap

Bootstrap Estimation
check-matrix

Check Matrix
check-numeric-comparison

Check Numeric Relations
check-numeric-trend

Check Numeric Trend
check-numeric

Check Numeric Values