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

`read_fwf` and `vroom_fwf` accidentally skipping first lines?

I'm sure I'm doing something silly, but I can't quite figure it out. Both read_fwf and vroom_fwf are producing files that lack one line (the first line, to be precise) when importing fixed-width files. There are two…
Kim
  • 4,080
  • 2
  • 30
  • 51
2
votes
1 answer

Use a string to assign multiple column types to tibble

The following data has six columns. I want to change all their column types, respectively to factor-factor-factor-int-int-factor. d <- structure(list(a = c(9, 9, 9, 9, 9, 9, 9), b = structure(c(2018, 2018, 2018, 2018, 2018, 2018, 2018), class =…
FBr
  • 23
  • 5
2
votes
0 answers

readr vs data.table different results on Fedora

I replaced Ubuntu 20.04 with Fedora 37 on my laptop (clean install, 16 GB RAM) to follow my lab's standard and, curiously, readr doesn't work with a 6.7 GB csv file in this specific case (it crashes RStudio). What can explain this? readr worked with…
pachadotdev
  • 3,345
  • 6
  • 33
  • 60
2
votes
0 answers

read_csv() parsing error message, what's the issue?

I'm just fooling around with the different parsing functions in the readr package and came across this error when working with read_csv(): read_csv("data frame consisting of fruit types lets see if we can skip these first two rows …
2
votes
1 answer

read_csv crashes because "too many files open"

I have several folders with ca 10000 small csv files that I'd like to quickly read into memory and stitch together into one data frame per folder. readr's read_csv can do this conveniently since it accepts vectors of file paths directly and does the…
Simon
  • 25
  • 4
2
votes
0 answers

How to read csv with \" within quoted string with read_csv_arrow

I have a large csv file that I'd like to read with arrow::read_csv_arrow(). However, the file contains quoted strings. readr::read_delim() is able to read the file (given correct settings), while arrow::read_csv_arrow() is…
Thomas K
  • 3,242
  • 15
  • 29
2
votes
1 answer

Is it possible to use tidyselect helpers with the cols_only() function?

I have a .csv file like this (except that the real .csv file has many more columns): library(tidyverse) tibble(id1 = c("a", "b"), id2 = c("c", "d"), data1 = c(1, 2), data2 = c(3, 4), data1s = c(5, 6), data2s =…
nicholas
  • 903
  • 2
  • 12
2
votes
0 answers

Newest version of readr gives error :Error in app$vspace(new_style$`margin-top` %||% 0) : attempt to apply non-function

I've seen a thread about my issue on stackoverflow and reddit but all the solutions I read are not working for me. I have the latest version of readr and R but I still get the same error when using the function read_delim. I also have tidyverse…
Debbie Oomen
  • 197
  • 1
  • 7
2
votes
2 answers

When reading in data from a zip-file in R, it corrupts the previous read-in data

My goal is to read in zip files directly from the web (opentransportdata.swiss). Each zip file contains multiple .txt files. In my example I am trying to retrieve the data of the routes.txt file. So my code is the following: library(tidyverse) #…
Oubi
  • 35
  • 5
2
votes
1 answer

R - for view_html() how can I change the limit to more than 100

I am trying to compare two data sets df1 and df2, both having 1000 rows and 161 columns which I have loaded from Excel. When I use compare_df(df1, df2) and then try to view the HTML output by view_html(compare_df(df1, df2)) to see the difference, I…
kaydee
  • 67
  • 5
2
votes
1 answer

readr::read_csv use cols_only with spliced list

I am able to read in a subset of columns defined in cols_only like so: x <- read_csv(filePath, col_types=cols_only(colA=col_character()) x <- read_csv(filePath, col_types=cols_only(colA='c')) Both work fine, but I tried to create a list to pass…
Raesu
  • 310
  • 2
  • 15
2
votes
5 answers

Is there an R function that reads text files with \n as a (column) delimiter?

The Problem I'm trying to come up with a neat/fast way to read files delimited by newline (\n) characters into more than one column. Essentially in a given input file, multiple rows in the input file should become a single row in the output, however…
Sam Rogers
  • 787
  • 1
  • 8
  • 19
2
votes
2 answers

readr::read_lines: Problem with lines length result for empty *txt files

I have 4K *txt files where the numbers of lines are important because if my *txt file is empty a need to count zero and if I have 1 or more lines this information is informative too. But the function read_lines in readr package give to me 1 line…
Leprechault
  • 1,531
  • 12
  • 28
2
votes
2 answers

Struggling to use read_tsv() in place of read.csv()

ANSWERED: Thank you so much Bob, ffs the issue was not specifying comment='#'. Why this works, when 'skip' should've skipped the offending lines remains a mystery. Also see Gray's comment re: Excel's 'Text to Columns' feature for a non-R…
Brett
  • 45
  • 8
2
votes
1 answer

Python: write CSV with QUOTE_NONNUMERIC, except for None

Given the data ['a', '', None, 5] I would like to write a CSV file as: "a","",,5 If I use QUOTE_NONNUMERIC, as in: import csv with open('eggs.csv', 'w') as csvfile: spamwriter = csv.writer(csvfile, quoting=csv.QUOTE_NONNUMERIC) …
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165