Learn R Programming

fecR (version 0.0.2)

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

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

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

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.

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.

See Also

This function is used by check_format.

Examples

Run this code
# NOT RUN {
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")
# }

Run the code above in your browser using DataLab