Questions tagged [readxl]

an R package that can be used to import Excel (.xls and .xlsx) files into R

The readxl package can be used to import Excel (.xls and .xlsx) files into R. It has no external dependencies (the libxls C library is embedded) and works on Windows, Mac, and Linux.

Resources

356 questions
2
votes
2 answers

Read limited number of rows from excel file in R with read_excel

I am reading in excel files in R using the readxl package like this: library(readxl) file_names <- list.files(pattern = ".xlsx") list_collection <- list() for(i in 1:length(file_names)){ frame <- read_excel(file_names[i], ) frame_sub <-…
Cybernetic
  • 12,628
  • 16
  • 93
  • 132
1
vote
1 answer

Extract iteratively data in subfolders within folder into googledrive

In a general folder, I have this subset of subfolders which I would like to open iteratively to download datasets in .xlsx format In the following major folder: there are these subfolders that as you could see has a specific pattern name and…
12666727b9
  • 1,133
  • 1
  • 8
  • 22
1
vote
2 answers

Update: Automating manual Excel read and clean for multiple spreadsheets with headers and subheaders in R; prefer to use dplyr to address messy data

I have multiple Excel files per year that I need to read in. Each file has multiple spreadsheets that are relevant for my analysis and I'd like to keep only those. The problem is that the first 3 rows are headers and sub-headers that I need…
1
vote
1 answer

How to import & bind multiple excel with multiple tabs (Names common)

I want to import multiple excel files. Each file contains 3 tabs with same name with other files. Eg. Studentname,studentdivision, studentmarks. I want to import all files and bind them in unique tabs and export one file with these 3 tabs data Need…
1
vote
1 answer

R: how to import a few non-contiguous columns using readxl?

I only want to import columns 1, 2, 4, 5 of my .xlsx file, so I tried: read_xlsx(path, range=cell_cols(c(1, 2, 4, 5)) However, this imports all columns from column 1 to 5 (i.e. columns 1, 2, 3, 4, 5). Not what I want. I cannot find the right way to…
francoiskroll
  • 1,026
  • 3
  • 13
  • 24
1
vote
1 answer

Is there a way in R to read multiple excel files, change columns to character, and then merge them?

New-ish to R and I feel like this has a simple solution, but I can't figure it out. I have 59 excel files that I want to combine. However, 4 of the columns have a mix of dates and NA's (depending on if the study animal is a migrant or not) so R…
1
vote
3 answers

How to import multiple excel sheets with tabs named in numeric only in R

I have an excel workbook with 100s of sheets with tab named as strings (sheet1, R Import, etc.) and numeric (123, 456, etc.). But I want to import all the sheets for which the tab names are in numeric only. I have the following code to import all…
aseb
  • 27
  • 3
1
vote
1 answer

Why does the variable name in my imported dataset have random characters added to it?

It's a bit tricky to provide a reproducible example, but my issue is that I am bringing in a dataset of British Geological Society mineral production data (after some slight tidying in Excel). Specifically, from this website I'm downloading a .xlsx…
Jay Bee
  • 362
  • 1
  • 9
1
vote
2 answers

Mass import and shaping of data in R

SOF newbie here, so please bear with me and some daft questions! Can anyone please tell me what the most efficient way would be to read in ~50+ excel files with multiple tabs into R, select a specific tab from all 50, and combine those tabs by date…
SOFaddict
  • 13
  • 4
1
vote
0 answers

readxl::read_excel() read excel file path containing Chinese characters returns in utils::unzip(zip_path, list = TRUE)

After setting locale and main path with code below: Sys.setlocale(category = "LC_CTYPE", locale = "chinese") setwd('D:/lyz用户名/R可视化/') I used readxl::read_excel() and xlsx::read.xlsx() to read the path of excel file containing Chinese characters…
ah bon
  • 9,293
  • 12
  • 65
  • 148
1
vote
1 answer

R: read in multiple .xlxs files from AWS S3

I am quite new to R and I have a problem which I think needs solving by a loop... I have multiple .xlsx files in AWS S3: (note the naming of each do not follow a pattern) File name 1: climate_change.xlsx File name 2: farming.xlsx etc etc Each…
fe108
  • 161
  • 7
1
vote
1 answer

Read multiple “.xlsx” files

I am trying to read multiple excel files under different folders by R Here is my solution: setwd("D:/data") filename <- list.files(getwd(),full.names = TRUE) # Four folders "epdata1" "epdata2" "epdata3" "epdata4" were inside the folder…
Clare Su
  • 11
  • 1
1
vote
0 answers

Read_excel having trouble with filepaths

I have a list of file paths saved in a character called pwb_files_e1. Some of the pathways have apostrophes in the string. I have a fairly long for-loop that goes through the various files, saves selected information from the relevant rows in the…
1
vote
1 answer

How to skip empty rows while reading multiple tabs in R?

I am trying to read an excel file with multiple tabs. For that, I use the code provided here. The problem is that each tab has a different number of empty rows before the actual data begins. For example, the first tab has two empty rows, the second…
Oleg Ivanytskyi
  • 959
  • 2
  • 12
  • 28
1
vote
1 answer

How do I get R to work with spaces in a file path?

I believe a switch to OneDrive is causing some issues in various packages in R due to spaces being incorporated into the file path name. One shown below is the readxl package. Is there a way to get the package to read the spaces in the file path…
Scott R
  • 133
  • 2
  • 13