Questions tagged [readr]

readr is an R package that provides a fast and friendly way to read tabular data.

An R package written by Hadley Wickham. The goal of readr is to provide a fast and friendly way to read tabular data into R.

527 questions
8
votes
1 answer

What does read_csv() use random numbers for?

I just noticed that read_csv() somehow uses random numbers which is unexpected (at least to me). The corresponding base R function read.csv() does not do that. So, what does read_csv() use the random numbers for? I looked into the documentation but…
AlbertRapp
  • 408
  • 2
  • 9
8
votes
2 answers

What is the practical difference between read_csv and read.csv? When should one be used over another?

I often work with comma separated values, and was curious to the differences between read_csv() and read.csv(). Are there any practical differences that could shine light on the situational usage of both?
mhovd
  • 3,724
  • 2
  • 21
  • 47
8
votes
1 answer

How to use "cols()" and "col_double" with respect to comma as decimal mark

I would like to parse my columns with the readr package to the right type while reading. Difficulty: the fields are separated by semicolon (;), while comma (,) is used as decimal mark. library(readr) # Test data: T <- "Date;Time;Var1;Var2 …
Pelle
  • 257
  • 2
  • 8
8
votes
2 answers

Could not find function "OlsonNames" when using read_csv with readr package

I am trying to read a csv file using read_csv() of R. library(readr) data <- read_csv("data/tmp.csv") tmp.csv is given below. "A", "B", "C", "D", "E", "F", "G", "H",…
Quazi Marufur Rahman
  • 2,603
  • 5
  • 33
  • 51
8
votes
1 answer

What are the file formats that read into R the fastest?

It seems most intuitive that .rdata files might be the fasted file format for R to load, but when scanning some of the stack posts it seems that more attention has been on enhancing load times for .csv or other formats. Is there a definitive answer?
7
votes
2 answers

r, write_csv is changing all times/dates to UTC

I have found a very annoying problem that I want to share with the community. This is a question that I have found an acceptable solution for (detailed below), but I now have several follow-up questions. My knowledge of time stamps and POSIX…
Phil_T
  • 942
  • 9
  • 27
7
votes
1 answer

readr - how to update col_spec object from spec()

I like the workflow regarding column specs as described in this RStudio blog post. Basically, one can grab the column specification after a read_csv import, and then save that down for use later. For example, from that post: mtcars2 <-…
Rafael Zayas
  • 2,061
  • 1
  • 18
  • 20
7
votes
4 answers

R: How can I read a CSV file with data.table::fread, that has a comma as decimal and point as thousand separator="."

I got several CSV files which contain numbers in the local german style i.e. with a comma as the decimal separator and the point as the thousand separator e.g. 10.380,45. The values in the CSV file are separated by ";". The files also contain…
PhiSeu
  • 301
  • 2
  • 9
6
votes
2 answers

Importing unquoted strings as factors using read_csv from the readr package in R

I have a .csv datafile with many columns. Unfortunately, string values do not have quotation marks (i.e., apples i.o. "apples). When I use read_csv from the readr package, the string values are imported as characters: library(readr) mydat =…
user2363777
  • 947
  • 8
  • 18
6
votes
1 answer

readr - Importing date column in CSV

I need an advice as to how import data using readr by inputing my own date format The way i am trying is: read_csv("test", col_types = cols( column-name = col_date("02/03/2015", "%d/%m/%Y)) But its giving me error " Error in col_date("02/03/2015",…
Adeel Sarwar
  • 61
  • 1
  • 2
5
votes
3 answers

Read whitespace-delimited Stack Overflow data with row numbers directly into R

Often Stack Overflow R questions can share sample data that is just data.frame output as such, instead of dput: id cate result 1 1 yes 1 2 1 yes NA 3 1 no NA 4 2 no NA 5 2 yes 1 6 2…
dcsuka
  • 2,922
  • 3
  • 6
  • 27
5
votes
0 answers

read_csv() with german special character in path

I am trying to import a CSV, but my windows username has an "ö" in it. library(tidyverse) persons <- read_csv("./data/persons.csv") This is the error message (anonymized) Error in guess_header_(datasource, tokenizer, locale) : Cannot read …
PalimPalim
  • 2,892
  • 1
  • 18
  • 40
5
votes
1 answer

reading zip file directly with read_csv from readr producing weird results

I'm trying to read directly from a URL to grab a zip file that contains a pipe delimited text file. If I download the file, then use read_csv to read it from disk, I have no problems. But if I try to use read_csv to read the URL directly I get…
JD Long
  • 59,675
  • 58
  • 202
  • 294
5
votes
0 answers

How can the decimal mark for the current system locale be determined in R?

I want to use readr::parse_number() for a character vector that was guessed as type "number" by readr::guess_parser() I can construct a locale to make this work using readr::parse_number( readr::locale(decimal_mark =
MilesMcBain
  • 1,115
  • 10
  • 12
5
votes
2 answers

Ignore trailing delimiters in readr::read_csv()

When I read a CSV file containing a trailing delimiter using readr::read_csv(), I get a warning that a new name for the last column was created. Here is the contents of a short example file to show what a…
cbrnr
  • 1,564
  • 1
  • 14
  • 28
1
2
3
35 36