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
3 answers

R: import and merge only specific columns

I have a list of CSV URLs from the net and have merged them to a vector. Now, I want to read this list with read_csv. Example: files <- c("csv_link1.csv", "csv_link2.csv", "csv_link3.csv", and so on....) data…
pontilicious
  • 239
  • 2
  • 12
1
vote
1 answer

R regex to list files that do not begin with eg `AA` or `BB`

Here's the reprex we'll need to create in our working directory: library(tidyverse) library(openxlsx) library(readxl) write.xlsx(list(iris), "AA-excel-file.xlsx") write.xlsx(list(iris), "BB-excel-file.xlsx") write.xlsx(list(iris),…
Display name
  • 4,153
  • 5
  • 27
  • 75
1
vote
2 answers

R: read_csv reads numeric entries as logical - parsing col_logical instead of col_double

I am new to R. I wrote a code for an assignment which reads several csv files and binds it into a data frame and then according to the id, calculates the mean of either nitrate or sulfate. Data sample: Date sulfate nitrate ID
MaPe
  • 33
  • 6
1
vote
0 answers

Treatment of mostly blank columns using readr::spec_csv

I'm reading a lot of sparse data where 90%+ of many character columns are blank or a single space. Using readr::read_csv it will guess these columns as logical if the first 1000 rows have no data (by design as per…
Matt_B
  • 824
  • 1
  • 6
  • 13
1
vote
0 answers

How to read a .txt file into a dataframe with readr?

I have the following data that I obtained from a .txt file using the read_lines function from readr txtread<-read_lines("expenses_copy1.txt") txtread [1] "Amount:Category:Date:Description" [2]…
Nathan123
  • 763
  • 5
  • 18
1
vote
1 answer

Problem saving decimal numbers with readr::write_csv, what to do?

I'm using readr::write_csv() to export a data.frame in the .csv format to another system. By doing that I noticed that write_csv() increases the number of some decimals, which is a problem for the other application. You can reproduce this behavior…
Marcos
  • 103
  • 6
1
vote
1 answer

Parse an hungarian date with readr::parse_date

I'm not able to parse very simple hungarian dates with readr::parse_date parse_date('július 6.', format = '%B %e.', locale = locale('hu')) even if the month is listed in the locale > locale('hu') Numbers: 123,456.78 Formats: %AD /…
Bakaburg
  • 3,165
  • 4
  • 32
  • 64
1
vote
1 answer

What is the problem with a txt file when trying to read this into R environment?

I am trying to read a txt file into R environment. I do not understand what is the problem with it and why I cannot read the txt into columns. Can someone explain to me what is the actual problem here? Because that will enable me to search properly…
GaB
  • 1,076
  • 2
  • 16
  • 29
1
vote
0 answers

saving character vector so that output file shows regex special characters

I have a character vector which includes regex special characters such as \n. I want to save this vector to a txt-file which shows the \n. The code below creates a txt file, but when opening the file e.g. in notepad, the \n are translated into…
zoowalk
  • 2,018
  • 20
  • 33
1
vote
1 answer

Read data in a url in R

I want to read the data in the following url into R but I couldn't do it. Does anyone have any idea about it?? Thanks! http://web.stanford.edu/~hastie/ElemStatLearn/ I need the data Ozone
user10386405
  • 137
  • 5
1
vote
1 answer

Using tidyverse to read data from s3 bucket

I'm trying to read a .csv file stored in an s3 bucket, and I'm getting errors. I'm following the instructions here, but either it does not work or I am making a mistake and I'm not getting what I'm doing wrong. Here's what I'm trying to do: # I'm…
Barranka
  • 20,547
  • 13
  • 65
  • 83
1
vote
1 answer

readr::read_tsv() parsing failures due to trailing tabs

Issue/Question I have tab-delimited my-data.txt file with 51 columns. The col_names row has no trailing tabs and readr::read_tsv() correctly detects 51 columns. However, the data columns all contain trailing tabs and readr::read_tsv() interprets…
maia-sh
  • 537
  • 4
  • 14
1
vote
1 answer

read_csv() adds "\r" to *.csv input

I'm trying to read in a small (17kb), simple csv file from EdX.org (for an online course), and I've never had this trouble with readr::read_csv() before. Base-R read.csv() reads the file without generating the problem. A small (17kb) csv file from…
Jeremy K.
  • 1,710
  • 14
  • 35
1
vote
1 answer

R read .txt document having encoding ‘ANSI’(windows base) having correct Swedish character

I am using a windows based machine. I have a test.txt document that has encoding as 'ANSI' having Swedish Characters inside. I hope I can read the information to R for further analyses. any suggestion? the current solution I have is I need to save…
CloverCeline
  • 511
  • 3
  • 18
1
vote
2 answers

How to append data with readr::write_excel_csv without repeating column names?

The help file for readr::write_excel_csv suggests the following code usage: write_excel_csv(x, path, na = "NA", append = TRUE, col_names = !append, delim = ",", quote_escape = "double") However, col_names = !append creates an…
Susie Derkins
  • 2,506
  • 2
  • 13
  • 21