Skip to content

A easy way to read all columns as character #148

Closed

Description

@TuSKan

Hi Hadley,

I couldn't find a easier way to read all columns as a character than this:
header <- read_csv("file.csv", n_max = 1)
read_csv("file.csv", col_types = paste0(rep("c", ncol(header)), collapse = "") )
I will be great to specify just one type for all columns like that:
read_csv("file.csv", col_types = "c" )

Activity

  1. leoluyi commented on Apr 30, 2015

    @leoluyi

    Need one-for-all, auto recycled col_types argument setting, too!

    It would be very helpful when one doesn't want col type to be imputed, but to keep all the data information as character for following manipulations.

  2. hadley commented on Sep 22, 2015

    @hadley
    Member

    You can now do col_types = cols(.default = "c")

  3. leoluyi commented on Oct 16, 2015

    @leoluyi
    devtools::install_github("hadley/readr")
    x <- "A\tB\n1\tD"
    readr::read_tsv(x, col_types = cols(.default = "c"))

    got this error message

    Error: not compatible with STRSXP
    In addition: Warning message:
    Unnamed `col_types` should have the same length as `col_names`. Using smaller of the two. 
    

    (readr version 0.1.1.9000)

  4. hadley commented on Oct 16, 2015

    @hadley
    Member

    @leoluyi please open a new issue

  5. locked and limited conversation to collaborators on Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions