inst/doc/column-types.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(readr)

## -----------------------------------------------------------------------------
tricky_dat <- tibble::tibble(
  x = rep(c("", "2"), c(1000, 1)),
  y = "y"
)
tfile <- tempfile("tricky-column-type-guessing-", fileext = ".csv")
write_csv(tricky_dat, tfile)

## -----------------------------------------------------------------------------
df <- with_edition(1, read_csv(tfile))
tail(df)

## -----------------------------------------------------------------------------
df <- with_edition(1, read_csv(tfile, guess_max = 1001))
tail(df)

## -----------------------------------------------------------------------------
df <- with_edition(1, read_csv(tfile, col_types = list(x = col_double())))
tail(df)

## -----------------------------------------------------------------------------
file.remove(tfile)

Try the readr package in your browser

Any scripts or data that you put into this service are public.

readr documentation built on May 29, 2024, 2:37 a.m.