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
1
vote
2 answers

Parsing txt file in R

I need to parse a txt file like this: 2021 Sep 27 15:54:50 avg_dur = 0.321 s 2021 Sep 27 15:54:52 avg_dur = 0.036 s 2021 Sep 27 15:54:54 avg_dur = 0.350 s 2021 Sep 27 15:54:56 avg_dur = 0.317 s I…
Stefano Bossi
  • 1,138
  • 1
  • 9
  • 19
1
vote
1 answer

getting error for "NA" values while reading file using read_csv() using tiddyverse

I am trying to read a file in which a column generally contains a double but when the value is neutral it has "Calm" as its value. So when I read the file I am using na = "Calm | calm" and inside col_types = cols() I am parsing the column using '9am…
1
vote
0 answers

R readr read_csv skip error with VROOM_CONNECTION_SIZE

I have a large (~18gb) csv file that I would like to read in chuncks. The chuncks are separately processed (filtered) and concatenated. Since I'm iterating through several chunks I'm using the skip parameter of the read_csv function. Here is an…
1
vote
1 answer

Read CSV file with delim in the quote using read_csv

The csv file contains comma (,) in the quotation. read_csv function convert them into numeric numbers which suppose to keep as character. library(readr) read_csv('"Name","V1","V2"\n "A","0,20","300,200"\n "B","0,20","300,200"') The results look…
Bangyou
  • 9,462
  • 16
  • 62
  • 94
1
vote
1 answer

deleting a column while loading excel into R

I have an Excel that I need to load into R. Excel have columns for example - A,B,C,D,E I am trying to load it and arrange the excel in the below way- df1 <- read_excel("abc.xlsx") %>% arrange(A) The above code would load the excel with…
kaydee
  • 67
  • 5
1
vote
2 answers

R changing Excel Date columns Datatype to Logical during read_excel() if Date column is empty in excel

So I have 2 excels VIN1.xlsx and VIN2.xlsx that I need to compare. VIN1 excel has a dale column OUTGATE_DT which is populated for atleast 1 rows. VIN2 excel has a date column OUTGATE_DT which is completely null for all rows. when I import VIN1.xlsx…
kaydee
  • 67
  • 5
1
vote
0 answers

"Warning: parsing failures" in readr package in R read_table2()

I have been trying to process a fairly large file (2 million-plus observations) using the reader package. However, using the read_table2() function (for that matter, read_table()) also generates the following error: Warning: 2441218 parsing…
1
vote
1 answer

Define one column only when reading in a list of csv files?

I'm reading in a list of files and combining into a single df with: fi <- list.files(path = 'data', pattern = '*.csv', full.names = T) %>% map_df(~read_csv(paste0(.))) But this is hitting an error: Error: Can't combine App ID and…
user14328853
  • 414
  • 2
  • 10
1
vote
4 answers

How to read a csv-file from an url in R?

I'm rather new to R and I could use your assistance. I am currently trying to import a csv file from an URL. I have found many examples. Unfortunately, none of them work for my problem. Specifically, I wanted to import the file from this url:…
rs_cit
  • 27
  • 5
1
vote
3 answers

access and filter explicit NA values created by parse_factor()

readr::parse_factor() is the tidyverse way to create factor variables. By default, it sets include_na = TRUE: an explicit NA level will be created for NA values in the vector that is passed to parse_factor(). After a factor variable has been created…
user697473
  • 2,165
  • 1
  • 20
  • 47
1
vote
1 answer

how to parse this encoded tsv

I tried to parse this tsv file using reader::read_tsv but I keep getting error of parsing failures. Then I realised that the tsv contained some unusual characters, when I used python to read the file it says encoding='cp1252' I have tried using…
KKW
  • 367
  • 1
  • 11
1
vote
1 answer

Why are the results of read_csv larger than those of read.csv?

I am importing many (> 300) .csv-files in a project, and I stumbled upon a very strange occurence. There is a noticable difference in size when comparing the results of read_csv and read.csv. Windows lists the file size of all files to be ~442…
mhovd
  • 3,724
  • 2
  • 21
  • 47
1
vote
2 answers

What is the most efficient read csv function / package in R at importing a subset of csv columns

I am trying to load a csv into R that is c. 180k rows and c.9k columns. I only need a subset of c.100 columns, and know the names of the columns that I need. The answers for this question cover a lot of the different options for selecting a subset…
Keynes2.0
  • 31
  • 3
1
vote
1 answer

Importing multiple csv files with read_csv in r

I have a vector with the names of multiple csv files. library(readr) data<-c("categories.csv", "customers.csv", "employees.csv", "employee_territories.csv", "order_details.csv", "orders.csv", "products.csv", …
1
vote
1 answer

Loading tidyverse leads to error message there is no package called 'readr'

I'm still new to R and just installed R on a new MacBook Pro and received the following error message when loading tidy verse. Grateful for any help! library(tidyverse) Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <-…
Phil
  • 31
  • 1
  • 1
  • 7