diff --git a/R/parser.R b/R/parser.R index e7f0a8f..ce2ef3a 100644 --- a/R/parser.R +++ b/R/parser.R @@ -28,6 +28,7 @@ collector_find <- function(name) { #' @param .return_problems Whether to hide the `problems` tibble from the output #' @keywords internal #' @export +#' @return a parsed vector #' @examples #' x <- c("1", "2", "3", "NA") #' parse_vector(x, col_integer()) @@ -65,6 +66,7 @@ parse_vector <- function(x, collector, na = c("", "NA"), locale = default_locale #' each field before parsing it? #' @inheritParams parse_vector #' @family parsers +#' @return a parsed vector #' @examples #' parse_integer(c("1", "2", "3")) #' parse_double(c("1", "2", "3.123")) @@ -129,11 +131,7 @@ col_character <- function() { collector("character") } -#' Skip a column -#' -#' Use this function to ignore a column when parsing. -#' To skip all columns not otherwise specified, use [cols_only()]. -#' +#' @rdname cols #' @family parsers #' @export col_skip <- function() { @@ -150,6 +148,7 @@ col_skip <- function() { #' @return A numeric vector (double) of parsed numbers. #' @family parsers #' @export +#' @return a parsed vector #' @examples #' ## These all return 1000 #' parse_number("$1,000") ## leading `$` and grouping character `,` ignored @@ -187,6 +186,7 @@ col_number <- function() { #' @param guess_integer If `TRUE`, guess integer types for whole numbers, if #' `FALSE` guess numeric type for all numbers. #' @family parsers +#' @return a parsed vector #' @export #' @examples #' # Logical vectors @@ -232,6 +232,7 @@ guess_parser <- function(x, locale = default_locale(), guess_integer = FALSE, na #' is included in the levels of the constructed factor. #' #' @inheritParams parse_atomic +#' @return a parsed vector #' @family parsers #' @export #' @examples @@ -464,6 +465,7 @@ col_time <- function(format = "") { #' ASCII? This is useful if you're dealing with ASCII data where the correct #' spellings have been lost. Requires the \pkg{stringi} package. #' @export +#' @return a list / S3 object representing the locale information #' @examples #' locale() #' locale("fr") @@ -569,6 +571,7 @@ check_encoding <- function(x) { #' @param mon,mon_ab Full and abbreviated month names. #' @param day,day_ab Full and abbreviated week day names. Starts with Sunday. #' @param am_pm Names used for AM and PM. +#' @return a list / S3 object representing data time #' @export #' @examples #' date_names_lang("en") @@ -649,6 +652,7 @@ is.date_names <- function(x) inherits(x, "date_names") #' @param .default Any named columns not explicitly overridden in `...` #' will be read with this column type. #' @export +#' @return a list / S3 object representing column specification #' @examples #' cols(a = col_integer()) #' cols_only(a = col_integer()) @@ -722,6 +726,7 @@ is.col_spec <- function(x) inherits(x, "col_spec") #' @keywords internal #' @examples #' as.col_spec("cccnnn") +#' @return a list / S3 object representing column specification #' @export as.col_spec <- function(x) UseMethod("as.col_spec") #' @export diff --git a/R/type_convert.R b/R/type_convert.R index ff0ef2c..3537a21 100644 --- a/R/type_convert.R +++ b/R/type_convert.R @@ -14,6 +14,7 @@ #' @inheritParams parse_guess #' @note `type_convert()` removes a 'spec' attribute (if it presents). #' @export +#' @return A data frame #' @examples #' df <- data.frame( #' x = as.character(runif(10)), diff --git a/man/as.col_spec.Rd b/man/as.col_spec.Rd index 3d3f4b4..597263c 100644 --- a/man/as.col_spec.Rd +++ b/man/as.col_spec.Rd @@ -9,6 +9,9 @@ as.col_spec(x) \arguments{ \item{x}{Input object} } +\value{ +a list / S3 object representing column specification +} \description{ This is most useful for generating a specification using the short form } diff --git a/man/col_skip.Rd b/man/col_skip.Rd deleted file mode 100644 index e32e849..0000000 --- a/man/col_skip.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/parser.R -\name{col_skip} -\alias{col_skip} -\title{Skip a column} -\usage{ -col_skip() -} -\description{ -Use this function to ignore a column when parsing. -To skip all columns not otherwise specified, use \code{\link[=cols_only]{cols_only()}}. -} -\seealso{ -Other parsers: -\code{\link{cols}()}, -\code{\link{parse_datetime}()}, -\code{\link{parse_factor}()}, -\code{\link{parse_guess}()}, -\code{\link{parse_logical}()}, -\code{\link{parse_number}()}, -\code{\link{parse_vector}()} -} -\concept{parsers} diff --git a/man/cols.Rd b/man/cols.Rd index 2b505a1..97ad0d6 100644 --- a/man/cols.Rd +++ b/man/cols.Rd @@ -1,10 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/parser.R -\name{cols} +\name{col_skip} +\alias{col_skip} \alias{cols} \alias{cols_only} \title{Create column specification} \usage{ +col_skip() + cols(..., .default = col_guess()) cols_only(...) @@ -19,6 +22,9 @@ the column names exactly.} \item{.default}{Any named columns not explicitly overridden in \code{...} will be read with this column type.} } +\value{ +a list / S3 object representing column specification +} \description{ \code{cols()} includes all columns in the input data, guessing the column types as the default. \code{cols_only()} includes only the columns you explicitly @@ -67,7 +73,14 @@ t3 } \seealso{ Other parsers: -\code{\link{col_skip}()}, +\code{\link{parse_datetime}()}, +\code{\link{parse_factor}()}, +\code{\link{parse_guess}()}, +\code{\link{parse_logical}()}, +\code{\link{parse_number}()}, +\code{\link{parse_vector}()} + +Other parsers: \code{\link{parse_datetime}()}, \code{\link{parse_factor}()}, \code{\link{parse_guess}()}, diff --git a/man/date_names.Rd b/man/date_names.Rd index 3a1f3ea..d532bb7 100644 --- a/man/date_names.Rd +++ b/man/date_names.Rd @@ -23,6 +23,9 @@ date_names_langs() e.g. \code{"en"} for American English. See \code{date_names_langs()} for a complete list of available locales.} } +\value{ +a list / S3 object representing data time +} \description{ When parsing dates, you often need to know how weekdays of the week and months are represented as text. This pair of functions allows you to either diff --git a/man/locale.Rd b/man/locale.Rd index 5192613..497d180 100644 --- a/man/locale.Rd +++ b/man/locale.Rd @@ -50,6 +50,9 @@ DST. It is \emph{not} Eastern Standard Time. It's better to use ASCII? This is useful if you're dealing with ASCII data where the correct spellings have been lost. Requires the \pkg{stringi} package.} } +\value{ +a list / S3 object representing the locale information +} \description{ A locale object tries to capture all the defaults that can vary between countries. You set the locale in once, and the details are automatically diff --git a/man/parse_atomic.Rd b/man/parse_atomic.Rd index 937b124..916bcac 100644 --- a/man/parse_atomic.Rd +++ b/man/parse_atomic.Rd @@ -68,6 +68,9 @@ each field before parsing it?} \item{.return_problems}{Whether to hide the \code{problems} tibble from the output} } +\value{ +a parsed vector +} \description{ Use \verb{parse_*()} if you have a character vector you want to parse. } @@ -89,7 +92,6 @@ parse_double(x, na = "-") \seealso{ Other parsers: \code{\link{col_skip}()}, -\code{\link{cols}()}, \code{\link{parse_datetime}()}, \code{\link{parse_factor}()}, \code{\link{parse_guess}()}, diff --git a/man/parse_datetime.Rd b/man/parse_datetime.Rd index fd243bf..add1c31 100644 --- a/man/parse_datetime.Rd +++ b/man/parse_datetime.Rd @@ -195,7 +195,6 @@ parse_datetime("1979-10-14T1010", locale = locale(tz = "")) \seealso{ Other parsers: \code{\link{col_skip}()}, -\code{\link{cols}()}, \code{\link{parse_factor}()}, \code{\link{parse_guess}()}, \code{\link{parse_logical}()}, diff --git a/man/parse_factor.Rd b/man/parse_factor.Rd index 41f2f35..b58ecb8 100644 --- a/man/parse_factor.Rd +++ b/man/parse_factor.Rd @@ -44,6 +44,9 @@ each field before parsing it?} \item{.return_problems}{Whether to hide the \code{problems} tibble from the output} } +\value{ +a parsed vector +} \description{ \code{parse_factor()} is similar to \code{\link[=factor]{factor()}}. } @@ -71,7 +74,6 @@ parse_factor(x, levels = animals) \seealso{ Other parsers: \code{\link{col_skip}()}, -\code{\link{cols}()}, \code{\link{parse_datetime}()}, \code{\link{parse_guess}()}, \code{\link{parse_logical}()}, diff --git a/man/parse_guess.Rd b/man/parse_guess.Rd index 396e31e..0d5e225 100644 --- a/man/parse_guess.Rd +++ b/man/parse_guess.Rd @@ -36,6 +36,9 @@ each field before parsing it?} \item{.return_problems}{Whether to hide the \code{problems} tibble from the output} } +\value{ +a parsed vector +} \description{ \code{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 @@ -59,7 +62,6 @@ parse_guess(c("2010-10-10")) \seealso{ Other parsers: \code{\link{col_skip}()}, -\code{\link{cols}()}, \code{\link{parse_datetime}()}, \code{\link{parse_factor}()}, \code{\link{parse_logical}()}, diff --git a/man/parse_number.Rd b/man/parse_number.Rd index c5fbd3f..38f1069 100644 --- a/man/parse_number.Rd +++ b/man/parse_number.Rd @@ -34,6 +34,8 @@ each field before parsing it?} } \value{ A numeric vector (double) of parsed numbers. + +a parsed vector } \description{ This parses the first number it finds, dropping any non-numeric characters @@ -59,7 +61,6 @@ parse_number(c("1", "2", "3", "NA", "Nothing"), na = c("NA", "Nothing")) \seealso{ Other parsers: \code{\link{col_skip}()}, -\code{\link{cols}()}, \code{\link{parse_datetime}()}, \code{\link{parse_factor}()}, \code{\link{parse_guess}()}, diff --git a/man/parse_vector.Rd b/man/parse_vector.Rd index 623e1ed..2fae54c 100644 --- a/man/parse_vector.Rd +++ b/man/parse_vector.Rd @@ -20,6 +20,9 @@ parse_vector( \item{.return_problems}{Whether to hide the \code{problems} tibble from the output} } +\value{ +a parsed vector +} \description{ Parse a character vector. } @@ -31,7 +34,6 @@ parse_vector(x, col_double()) \seealso{ Other parsers: \code{\link{col_skip}()}, -\code{\link{cols}()}, \code{\link{parse_datetime}()}, \code{\link{parse_factor}()}, \code{\link{parse_guess}()}, diff --git a/man/type_convert.Rd b/man/type_convert.Rd index 4d570ce..eeac72b 100644 --- a/man/type_convert.Rd +++ b/man/type_convert.Rd @@ -39,6 +39,9 @@ names.} \item{verbose}{whether to print messages} } +\value{ +A data frame +} \description{ This is useful if you need to do some manual munging - you can read the columns in as character, clean it up with (e.g.) regular expressions and