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
4
votes
2 answers

readr::type_convert messes up time column

I have the following R data frame: zed # A tibble: 10 x 3 jersey_number first_name statistics.minutes 1 20 Marques 8:20 2 53 Brennan 00:00 3…
Canovice
  • 9,012
  • 22
  • 93
  • 211
4
votes
3 answers

Error write_csv thinks data.frame isn't TRUE, write.csv does

I'm trying to write out a .csv file. readr::write_csv seems to think that my file isn't a data.frame. When I run: PriceCostRaw <- write_csv(PriceCostRaw, "Price Cost Raw.csv") it returns this error: Error in write_delim(x, path, delim = ",", na =…
Ash Levitt
  • 153
  • 3
  • 11
4
votes
2 answers

Inconsistency in abbreviated month names in non-english (danish & norwegian)

I wish convert some dates in Norwegian to actual dates in R. I'm using readr, and it kind of works - but I stumbled upon an issue which really annoys me, and I don't really know how to get around it. Here is an illustration of my problem: >…
Kira
  • 85
  • 1
  • 9
4
votes
1 answer

Does readr read_csv allow one to specific the specific file in a zip

The readr package in the tidyverse has the option to automatically unpack a zip file and convert it to a tibble. But I have a zip file that holds multiple csv files. In the line of code below, SSPdataZip has three files in it. When I run it I get a…
JerryN
  • 2,356
  • 1
  • 15
  • 49
4
votes
2 answers

readr - loading a zipped csv file

From this code: require(readr) readK6 <- read_csv("./data/K6.csv.zip", col_types = c("character", "numeric")) I'm getting: Error: Unknown shortcut: h In addition: Warning message: Missing column names filled in: 'X1'…
andandandand
  • 21,946
  • 60
  • 170
  • 271
4
votes
1 answer

How to pass arguments to a callback function for readr::read_csv_chunked

I've been playing around with readr's read_delim_chunked functions. Based on the documentation, it's not clear how one can, or if it's possible, to pass arguments into the callback function. For instance, from the documentation example: # Cars with…
TinyHeero
  • 580
  • 1
  • 4
  • 18
4
votes
2 answers

readr import - could not allocate memory ... in C function 'R_AllocStringBuffer'

Having trouble loading a large text file; I'll post the code below. The file is ~65 GB and is separated using a "|". I have 10 of them. The process I'll describe below has worked for 9 files but the last file is giving me trouble. Note that about…
maxo
  • 83
  • 2
  • 8
4
votes
2 answers

write_csv read_csv with scientific notation after 1000th row

Writing a data frame with a mix of small integer entries (value less than 1000) and "large" ones (value 1000 or more) into csv file with write_csv() mixes scientific and non-scientific entries. If the first 1000 rows are small values but there is a…
Habert
  • 347
  • 2
  • 10
4
votes
1 answer

read into R data frame from cognos 8 file (utf 16) with readr

I am attempting to read csv files generated by cognos 8 into r using readr. Example file attached for reproducibility: Example csv file The following python code works: df = pd.read_table('csv_test.csv', encoding = 'utf-16') I've tried the…
d.ellis
  • 61
  • 6
4
votes
1 answer

Parsing double grouped number with readr::parse_double()

Code shows as: readr::parse_double("123,456,789.987", locale = locale(decimal_mark = ".", grouping_mark = ",")) where the expected result is: 123456789.987 But it turns out this throws an…
Yunlong Huang
  • 85
  • 1
  • 6
4
votes
1 answer

Write xml-object to disk

I have a big bunch of xml-files, which I need to process. For that matter I want to be able to read the files, and save the resulting list of objects to disk. I tried to save the list with readr::write_rds, but after reading it in again, the object…
Thomas K
  • 3,242
  • 15
  • 29
4
votes
3 answers

Reading chunked file into dataframe

I am fairly new to pandas/r, and I'm not quite sure how to go about reading this data into pandas or r for analysis. Currently, I was thinking I could use readr's read_chunkwise, or pandas's chunksize, but this may not be what I need. Is this really…
petergensler
  • 342
  • 2
  • 8
  • 23
4
votes
2 answers

How to make R's read_csv2() recognise the text characters properly

Trying to read a csv file using read_csv2() from readr package. The problem is read_csv2() doesn't recognise the characters properly while R's default read.csv2 successfully does. For example: the original value: KOZYATAĞI how read_csv2()…
kzmlbyrk
  • 583
  • 1
  • 4
  • 17
4
votes
1 answer

readr multiple columns' type at once

I try to handle with readr function. I mean, this is an example from readr github webpage: read_csv("iris.csv", col_types = list( Sepal.Length = col_double(), Sepal.Width = col_double(), Petal.Length = col_double(), Petal.Width =…
Nicolabo
  • 1,337
  • 12
  • 30
4
votes
2 answers

R readr single col_types

Is it possible within readr package to read in data and specify a single data type across all columns? Similar to base::read.table with colClasses = "character" or using the as.is argument. Unless the task, data headers, file encoding, etc are well…
gbartusk
  • 113
  • 2
  • 5