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
1 answer

Pandas: parse CSV differentiating between the missing value sentinel and a string that happens to equal it

The R readr read_csv function allows passing quoted_na=FALSE, which allows the parser to distinguish between the unquoted NA meaning a missing value, and a quoted "NA" meaning a string that happens to equal NA. Is there a way for the read_csv…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
2
votes
1 answer

How can I read a txt file with µ as delimiter?

I have a txt file which I would like to read in either Python or R (does not matter). I tried in R to change the locale with readr package, which can read the µ properly when changing to e.g. data<- read_delim("./weirdfile.txt","µ", escape_double =…
Paul
  • 45
  • 3
2
votes
1 answer

Reading a Fixed-Width Multi-Line File in R

I have data from a PDF file that I am reading into R. library(pdftools) library(readr) library(stringr) library(dplyr) results <- pdf_text("health_data.pdf") %>% readr::read_lines() When I read it in with this method, a character vector is…
daneshjai
  • 858
  • 3
  • 10
  • 17
2
votes
3 answers

How to load multiple files from a folder and use part of filename as column in dataset

I am slowly fumbling my way around R and learning lots thanks to forums like this and blogs. I have found a handy piece of code (below) to solve part of a new problem but now I am stuck. library(readr) library(dplyr) myFiles <- list.files(path =…
lachlindco
  • 35
  • 6
2
votes
1 answer

How to read data in R when some rows contain commas as thousand separator and " flag and the rows without decimals don´t have flag

Im loading in R a csv (separated by comma) that has quotes " wrapping each row that contains a column with a value with decimals, and the particular value is wrapped with double quotes "" , the rows without this issue, have no " wrapping the csv…
edperalt
  • 23
  • 5
2
votes
1 answer

importing and transforming many csv files

I am importing and transforming many files in an inefficient way. I was wondering if someone could show me a faster way using purr. The following code is what I tried, and it should give you the general pattern: data_2013 <- read_csv("data_2013")…
dano_
  • 303
  • 1
  • 8
2
votes
1 answer

Reshape data with multiple header rows in R

Julie Joe Measurement 1 Measurement 2 Measurement 1 Measurement 2 Part Number 1 33 32 33 31 Part Number 2 34 31 …
Display name
  • 4,153
  • 5
  • 27
  • 75
2
votes
2 answers

Importing multiple invoices (.PDF) in R. Turning them from strings to a tibble

So I'm doing a project where I need to load a numerous amount of .pdfs into R. This part is somewhat covered. The problem is when importing the pdfs into R, every line is a string. Not all the information in de the string is relevant. And in some of…
JHJH
  • 47
  • 6
2
votes
1 answer

specific col_type = col_double when number have comma and point, no trailing characters error

I have squared data in a txt file with "|" separator data with value like this no| value 1| 3,123.00 2| 1,122.75 import it with this code: library(readr) data <- read_delim("file.txt", "|", trim_ws = TRUE, locale = locale(decimal_mark = "."),…
2
votes
2 answers

Force `read_tsv` to decompress file

I'm wondering if there is a way to get readr::read_tsv to read block gzip files with .bgz extension. I could rename the files to have .gz (which read_tsv automatically recognizes) which does work, but I don't want to do that everytime I get new…
Jon Chung
  • 145
  • 5
2
votes
2 answers

read_csv use col_double() instead for all numeric columns

I would like to use readr::read_csv instead of read.csv, due to its speed and automatically converting dates. However there is one problem with how it handles numbers that are mostly integers, with a few floats sprinkled in. Is there a way to force…
dule arnaux
  • 3,500
  • 2
  • 14
  • 21
2
votes
1 answer

How to convert a string of space delimited to a data frame in r

I scraped this data from the OCC website and got returned an ascii file that is space delimited. I am looking to turn this string into a data frame. I have tried using read.table, readr::read_tsv, but I am not getting the results desired. Below is…
Jordan Wrong
  • 1,205
  • 1
  • 12
  • 32
2
votes
2 answers

Is there a variable that contains the current row for filtering a subset in R?

I want to filter a large dataframe that contains a latitude and longitude. I want to use the method distHaversine(), which generates the distance between two points by latitude and longitude. With that, I want to filter out measurements that are far…
2
votes
1 answer

Is parse_number supposed to fail when there are multiple periods in the string?

In the readr package in R, the parse_number function fails when there is more than one period in the string. Is this a bug, or is this by design? Examples follow: > library(readr) > parse_number("asf125") [1] 125 > parse_number("asf.125") [1]…
Jake Fisher
  • 3,220
  • 3
  • 26
  • 39
2
votes
2 answers

How to correctly print μ by write_csv?

write_csv() in readr outputs μ as µ. How to correctly output μ using write_csv()? library(tidyverse) x <- tribble(~x, 'µ') write_csv(x, 'test.csv')
Timespace
  • 5,101
  • 7
  • 23
  • 32