Skip to contents

parse_guess() returns the parser vector. This function uses a number of heuristics to determine which type of vector is "best". Generally they try to err of the side of safety, as it's straightforward to override the parsing choice if needed.

Usage

parse_guess(
  x,
  na = c("", "NA"),
  locale = default_locale(),
  trim_ws = TRUE,
  guess_integer = FALSE,
  guess_max = NA,
  .return_problems = FALSE
)

col_guess()

Arguments

x

Character vector of values to parse.

na

Character vector of strings to interpret as missing values. Set this option to character() to indicate no missing values.

locale

The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use locale() to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.

trim_ws

Should leading and trailing whitespace (ASCII spaces and tabs) be trimmed from each field before parsing it?

guess_integer

If TRUE, guess integer types for whole numbers, if FALSE guess numeric type for all numbers.

guess_max

Maximum number of data rows to use for guessing column types. NA: uses all data.

.return_problems

Whether to hide the problems tibble from the output

Value

a parsed vector

See also

Examples

# Logical vectors
parse_guess(c("FALSE", "TRUE", "F", "T"))
#> [1] FALSE  TRUE FALSE  TRUE

# Integers and doubles
parse_guess(c("1", "2", "3"))
#> [1] 1 2 3
parse_guess(c("1.6", "2.6", "3.4"))
#> [1] 1.6 2.6 3.4

# Numbers containing grouping mark
parse_guess("1,234,566")
#> [1] 1234566

# ISO 8601 date times
parse_guess(c("2010-10-10"))
#> [1] "2010-10-10"