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

show.progress in readr and knitr

I am currently working on a .Rmd notebook, RStudio version 1.1.442. Following the Knitr manual and different examples found also in various vignette, in my notebook I've asked readr (installed version: 1.1.1) not to show progress bar using a hidden…
CheTesta
  • 577
  • 4
  • 17
3
votes
2 answers

skipping to a certain position in a large txt file

I have over 100 .txt files on which i would like to do calculations. The files contain gaze data which is collected with an eye tracker. The first part of the data is the calibration part. It contains only a limited number of variables. Every line…
Bart R
  • 157
  • 1
  • 9
3
votes
0 answers

How can I save a "quoted" .csv file using readr::write_csv?

When saving data in R, if you use write.csv() with default arguments you get a quoted csv file like this: "a","b" "c","d" However, if you use readr::write_csv() you get by default (and it looks there's no option to change this) an unquoted…
mickkk
  • 1,172
  • 2
  • 17
  • 38
3
votes
1 answer

R read data set which has unequal column

I have a .csv data set which is separated by "," and has about 5,000 rows and "5" columns. However, for some columns, the content contains also ",", for example: 2660,11-01-2016,70.75,05-06-2013,I,,, 4080,26-02-2016,59.36,,D Thus, when I tried to…
rz.He
  • 199
  • 1
  • 8
3
votes
1 answer

readr::read_csv issue: Chinese Character becomes messy codes

I'm trying to import a dataset to RStudio, however I am stuck with Chinese characters, as they become messy codes. Here is the code: library(tidyverse) df <- read_csv("中文,英文\n英文,德文") df # A tibble: 1 x 2 `\xd6\xd0\xce\xc4` `Ӣ\xce\xc4` …
X.Jun
  • 378
  • 2
  • 7
3
votes
2 answers

Create a list from Tibble Columns

I have a tibble like this: > library(tidyverse) > tbl <- tibble(x = c('a', 'b', 'c'), y = 1:3) > tbl # A tibble: 3 x 2 x y 1 a 1 2 b 2 3 c 3 I would like to create a list where the names of the…
Tommaso Guerrini
  • 1,499
  • 5
  • 17
  • 33
3
votes
2 answers

How to skip second line is csv file while maintaining first line as column names with read_csv?

Qualtrics generates csv files with variable names in the first line and variable labels in the second line. I'd like to use read_csv() to read in my data while reading the first line as column names and then skipping the next line of variable…
Joe
  • 3,217
  • 3
  • 21
  • 37
3
votes
0 answers

readr::read_csv() -- pass vector of character column names to import

I am writing a function that accepts a vector of column names to be read from a CSV file using readr::read_csv(). I would like to read only the column names in the vector from the file, and I would like to use readr's default column-type guessing…
treysp
  • 663
  • 6
  • 17
3
votes
0 answers

R readr: get columns specification of existing data, not imported one?

I have a dataset created in an R session, that I want to 1) export as csv 2) save the readr-type column specifications separately. This will allow me to read this data later on, using read_csv() and specifying col_types from the file saved in 2).…
Matifou
  • 7,968
  • 3
  • 47
  • 52
3
votes
1 answer

timezone error reading csv

After googling for a couple of hours I have not found a solution to this problem. Basically when I run read_csv("some_file.csv") function from readr package I get the following error: Error: Unknown TZ UTC and csv is not read. The only way I can…
jc52766
  • 159
  • 2
  • 9
3
votes
1 answer

Silent type_convert

Is there a way to use the type_convert function from the readr package without it telling you what column specification it's using in the console. From the example in the ? help documentation: > df <- data.frame( + x = as.character(runif(10)), +…
Marijn Stevering
  • 1,204
  • 10
  • 24
3
votes
0 answers

fix errors in csv and fwf files (corrupted characters) when importing to R

I am importing data from large files (fwf and csv) that were once stored as tapes, so they may have errors created when writing-reading the tape. The old files are in fixed width file (fwf) format The newer files are in .csv format (with ";" as…
LucasMation
  • 2,408
  • 2
  • 22
  • 45
3
votes
1 answer

Read csv but skip escaped commas in strings

I have a csv file like this: id,name,value 1,peter,5 2,peter\,paul,3 How can I read this file and tell R that "\," does not indicate a new column, only ",". I have to add that file has 400mb. Thanks
spore234
  • 3,550
  • 6
  • 50
  • 76
3
votes
1 answer

R: readr: How to read a file that is provided via URL and gzipped

Readr is great for loading data. It can handle URLs and compression. I am trying to use a source that has both. How can this be done. See the error below. The first attempt fails. But when I first download the file and then read it, it works.…
userJT
  • 11,486
  • 20
  • 77
  • 88
3
votes
1 answer

dplyr - Rename column [EMPTY] created by readr

When using readr_0.1.1 to read in a .csv file with a missing field name, the name is automatically set to [EMPTY]: library("readr") library("dplyr") df <- read_csv(",foo\n1,bar") > names(df) [1] "[EMPTY]" "foo" I am trying to rename "[EMPTY]"…
paljenczy
  • 4,779
  • 8
  • 33
  • 46