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

How to install readr package for R in Opensuse

I try to install readr package for R. But I got a lot of errors and the package isn't installed. My setup: openSUSE Leap 15.4 x86_64 ICEWM R version 4.1.2 (2021-11-01) -- "Bird Hippie" RStudio 2023.06.0+421 "Mountain Hydrangea" Release…
1
vote
1 answer

read_tsv() crashes R, but only with data files

I'm trying to download data from a website via a text file, then load it into R via read_tsv using the following code: url_jobzones <- "https://www.onetcenter.org/dl_files/database/db_27_3_text/Job%20Zones.txt" jobzones_file_name <-…
1
vote
1 answer

Tables stacked below each other in csv - How do I import them in R?

I have a csv file that looks like this Header, Car, LapTime 1, Spa, 0 0, Ferrari, 2.1 0, Aston Martin, 2.3 1, Monza, 0 0, Ferrari, 2.5 0, Ford, 2.6 0, Aston Martin, 2.4 That is, the csv contains multiple subtables stacked below each other, where…
stollenm
  • 348
  • 1
  • 2
  • 11
1
vote
1 answer

R: Too big file for R Studio to read?

The size of my file is 335.1 MB. R Studio seems to have some diffulty in reading it. I got this pop up: Note, that I get two different error messages according to the readr function I use. read_csv > Mydata <-…
Gato
  • 389
  • 2
  • 12
1
vote
3 answers

Read a text file with one line and split it to multiple rows based on a delimiter

I want to import a .txt file in R dataframe using "readr" library functions such as read.delim, read.table, read.csv. The .txt file has only one single row which contains all data. This one row should be split into different rows during import and…
canergin
  • 11
  • 2
1
vote
1 answer

Problem with importing a CSV file with extremely long column names

library(readr) surveyData_twoConditions <- read_csv("Raw Data/Survey Data/fileName_extremelyLongColumnNames.csv", col_types = cols(`Start Date` = col_character())) I suspect that the column which is giving me problem…
Pss
  • 553
  • 4
  • 12
1
vote
1 answer

How can I save Time data to csv file using write_csv without T or Z character?

I'm trying to save some time information included data with write_csv. But it keeps showing T and Z character (ISO8601 format as I know). For example, 2022-12-12 08:00:00 is shown as 2022-12-12T08:00:00Z on csv file open with notepad. I want keep…
Jerison K
  • 61
  • 4
1
vote
2 answers

Iteratively skip the last rows in CSV files when using read_csv

I have a number of CSV files exported from our database, say site1_observations.csv, site2_observations.csv, site3_observations.csv etc. Each CSV looks like below (site1 for example): Column A Column B Column C # Team: all teams #…
Sam Lin
  • 39
  • 4
1
vote
1 answer

read_delim( ) from tidyverse cannot directly correct misaligned headers of text file as basic read.table() does

I am trying to use tidyverse read_delim() to read a tab-separated text file. I can easily use the basic R's read.table() with no problem but when I tested read_delim() with delim = "\t"; I got a problem. For example, I have a file below, "test.txt".…
Xiaokuan Wei
  • 135
  • 6
1
vote
0 answers

Issue with converting strings to postixct class

My csv file has datetime data in the format yyyy-mm-dd hh:mm:ss When I read the file using readr::read_csv(), the datetime fields are loaded into the data frame as character data. When I try to convert these columns using as.POSIXct(data_frame["col…
1
vote
1 answer

Parsing a bi-annual time variable

I wanted to parse a bi-annual time variable from a dataframe when reading it in using read_csv. The bi-annual time variable has the format Year-B1 and Year-B2. Here is a little example of how my data is looking like and what I want to…
Marie Veit
  • 27
  • 5
1
vote
1 answer

readr read_csv specify col_types default but override some columns by location (not by name)

I have data across many .csv files that has the following attributes: The vast majority of the columns are numeric. The number of numeric columns across the files varies. A few of the columns are character. The number and location of these…
jmuhlenkamp
  • 2,102
  • 1
  • 14
  • 37
1
vote
1 answer

Converting a space and tabulated separated table string nested in data frame to wide data in R

I am struggling to convert a nested tabular and space delimited character string to wide data. My data looks something like this: #Sample data df <- tibble(id = 1:3, text_table = c(NA, "P1\tP2\tL1\n …
TBP
  • 92
  • 6
1
vote
0 answers

memory use for reading the same .csv file using baseR::read.csv(), readr::read_csv(), data.table::fread(), and arrow::read_csv_arrow() in R

I tried to read the same .csv file using different functions in R (base::read.csv(), readr::read_csv(), data.table::fread(), and arrow::read_csv_arrow()), but this same file leads to very different sizes in memory. See an example…
Miao Cai
  • 902
  • 9
  • 25
1
vote
2 answers

Specify number of columns to read when first row is missing values

I have data from a logger that inserts timestamps as rows within the comma separated data. I've sorted out a way to wrangle those timestamps into a tidy data frame (thanks to the responses to this question). The issue I'm having now is that the…
JMDR
  • 121
  • 1
  • 8