Skip to contents

This function read an object of the class types from a text file. By default, the text file is assumed to contain one type on each line.

Usage

read_types(
  file,
  sep = NA,
  file_encoding = "UTF-8",
  trim_types = FALSE,
  remove_duplicates = FALSE,
  sort = FALSE,
  ...
)

Arguments

file

Name of the input file.

sep

If not is.na(sep), then sep must be a character vector of length one. In that case, sep is interpreted as a type separator in the input file. This separator the serves as an additional type separator, next to the end of each line. The end of a line always indicated a separator between types (in other words, types cannot cross lines).

file_encoding

The file encoding used in the input file.

trim_types

Logical. Should leading and trailing white space should be stripped from the types.

remove_duplicates

Logical. Should duplicates be removed from x prior to coercing to a vector of types.

sort

Logical. Should x be alphabetically sorted prior to coercing to a vector of types; this argument is ignored if remove_duplicates is TRUE, because the result of removing duplicates is always sorted.

...

Additional arguments (not implemented).

Value

Object of class types.

See also

Examples

.old_wd <- setwd(tempdir())
types <- as_types(c("first", "second", "third"))
write_types(types, "file_with_types.txt")
types_2 <- read_types("file_with_types.txt")
setwd(.old_wd)