character_column_check: Checks a character column in a fishing trip data column

Description Usage Arguments Details Value See Also Examples

View source: R/check_data.R

Description

Checks a character column in a fishing trip data column. Used by the check_format function when checking the format of the input data.

Usage

1
2
character_column_check(column, column_name, character_correct = FALSE,
  missing_correct = FALSE, unknown_value = "UNKNOWN")

Arguments

column

The column of data from the data.frame.

column_name

The name of the column.

character_correct

Should non-character strings be forced to be characters.

missing_correct

Should missing entries be corrected.

unknown_value

The value to replace missing entries with

Details

This function checks that entries in a data column are character strings. It is possible to attempt to correct non-character string entries by forcing them to be characters. The function also checks for missing entries in the data (either the R value NA or character strings "NA" or ""). It is possible to replace missing entries by a user defined value. Appropriate messages are printed to the screen.

Value

A list with the column (x, with or without attempted corrections) and a flag (ok) to indicate if the data is OK or has problems.

See Also

This function is used by check_format.

Examples

1
2
3
4
5
dat <- data.frame(gear = c("OTB","OTB",NA, "NA", ""), gt = 100, stringsAsFactors=FALSE)
# Check with no correction
check <- character_column_check(dat$gear, "gear")
# Check with correction
check <- character_column_check(dat$gear, "gear", missing_correct=TRUE, unknown_value = "NK")

fecR documentation built on Sept. 9, 2017, 5:03 p.m.