anderwyang
anderwyang

Reputation: 2431

In readr()/read_csv, how to import data with all columns as character

In readr()/read_csv, how to import data with all columns as character? Thanks!

library(tidyverse)    
read_csv(readr_example("mtcars.csv")))

Upvotes: 4

Views: 5572

Answers (2)

Lijing Bu
Lijing Bu

Reputation: 1

Update: use list(.default = col_character())) if cols(.default = col_character())) doesn't work for you.

Upvotes: 0

Will Oldham
Will Oldham

Reputation: 1054

You can pick a default column type using:

read_csv(readr_example("mtcars.csv"), col_types = cols(.default = col_character()))

The cols specification will also let you define specific columns as well.

Upvotes: 5

Related Questions