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

How to batch read 2.8 GB gzipped (40 GB TSVs) files into R?

I have a directory with 31 gzipped TSVs (2.8 GB compressed / 40 GB uncompressed). I would like to conditionally import all matching rows based on the value of 1 column, and combine into one data frame. I've read through several answers here, but…
Khashir
  • 341
  • 3
  • 20
2
votes
1 answer

Column wrongly tagged as int when is num

I have generated a dataframe that contains 9829 observations of 37 variables and saved it with write_csv. When loading this dataframe in shiny with read_csv one column is tagged as int when its values are floating numbers, this causes all floating…
Treizh
  • 322
  • 5
  • 12
2
votes
1 answer

readr forcing column type

I am trying to read in a CSV file - and am attempting to force the columns to be of a certain type. But the very last column gives me an error: "Error in is.list(col_types) : Unknown shortcut: g" Any advice, please? Thank you! library(readr) #…
user3245256
  • 1,842
  • 4
  • 24
  • 51
2
votes
0 answers

how do I write French accented characters to csv for excel?

I have a vector of raw text that includes English and French words, so there are French words that have accented characters like this: 1 entretien ménager 2 concepteur réseaux 3 service à la clientèle 4…
spindoctor
  • 1,719
  • 1
  • 18
  • 42
2
votes
1 answer

read_delim of literal data after modifications to huge character vector

I have a number of pipe-delimited files, a few very large (many GB), that are flawed. Someone mistakenly left out one field and a delimiter, but only in some of the rows. I'd like to read each file as a vector of character strings using…
Earl F Glynn
  • 375
  • 2
  • 7
2
votes
2 answers

creating a table from plain text with multi line entries in r

I have a PDF file with a table. I am using pdftools::pdf_text function to extract the text and I get a vector with several lines which represent the table. My problem is, that there are only spaces and some cells have multiple lines. I am looking…
drmariod
  • 11,106
  • 16
  • 64
  • 110
2
votes
1 answer

Read file and make every character in a separate column

I have a huge file (square data file of a sequence alignment) and want to put every position into a separate column, but readr::read_delim for instance can´t take empty delimiters, and for readr::read_fwf it seems that you need to specify every…
Jon
  • 591
  • 2
  • 8
  • 19
2
votes
1 answer

Reading a TSV with specific encoding (initial two bytes and UTF-8 afterwards) and NUL after each character

I have an obscure TSV that I'm trying to read and apparently it starts with a identifier and has some NUL values embedded (it seems that it's one NUL after each genuine character). These are the first 100 bytes of the file (shortened with a hex…
takje
  • 2,630
  • 28
  • 47
2
votes
0 answers

Write_csv output issues: yyyymmddThhmmssZ instead of yyyymmdd hhmmss

I have been messing around with the datetime formatting, as I have data that goes through daylight savings time. The csv files I read in skip an hour in the spring and then repeat one in the fall. This seems to mess up a loop I am using. So I am…
Andrew
  • 23
  • 4
2
votes
2 answers

"Warning message: Unknown or uninitialised column:df" after converting a few columns to numeric

I got this message after I convert a few columns from "characters" to "numeric": Warning message: Unknown or uninitialised column:df I needed to load a csv file (from Qualtrics) into R. filename <- "/Users/Study1.csv" library(readr) df <-…
JetLag
  • 296
  • 1
  • 4
  • 16
2
votes
1 answer

Text File in R not loading all the text in R

When I upload a file a text file into R the text is being truncated and i cant get an accurate count. Is there another command I should use so I the entire text file is read. library(stringr) > readr::read_file("Apple_Wikipedia.txt") [1] "Apple…
2
votes
1 answer

write_csv Error in stream_delim_(df, path, ...) : invalid connection

I have a doubt about why write_csv is not working in the following example, but write.csv is working properly. In general, I use the packages "dplyr" and "readr" as they are fast. However, I am not sure why this is happening. write_csv(df1, path =…
Sergio
  • 109
  • 1
  • 9
2
votes
3 answers

In R, read_csv() parsing failures: Converting integers into NA's

I just meet a problem when I use read_csv() and read.csv() to import CSV files into R. My file contains 1.7 million rows and 78 variables.Most of those variable are integers. When I use the read_csv(), some cells, which are integers, are converted…
Mars Chen
  • 103
  • 1
  • 2
  • 9
2
votes
2 answers

R: error with read_csv, 'sysdata.rdb': No such file or directory

I'm trying to use read_csv in R from tidyverse package but I always get this message: > read_csv(readr_example("mtcars.csv")) Error in date_names_lang(date_names) : cannot open file '~/R/win-library/3.4/readr/R/sysdata.rdb': No such file or…
Luca Monno
  • 830
  • 1
  • 11
  • 25
2
votes
2 answers

r:readr:write_csv how to have the file compressed?

A CSV file of 20MB+ is not polite to email. How a user can zip the file with least amount of code? Non zipped task is: mtcars %>% write_csv('foocars.csv') read_csv can nicely look at extensions and do unzipping. What would be easiest…
userJT
  • 11,486
  • 20
  • 77
  • 88