readxl

R: Use Regex to Import Specific Sheets from Multiple Excel Files

笑着哭i 提交于 2021-02-10 15:57:02
问题 I have a group of Excel files with multiple sheets which don’t follow a standard naming convention. I want to create a single data frame from specific sheets containing the keyword 'frame' . library(tidyverse) library(openxlsx) # Sample Excel File 1 df1 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) data_frame2 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) list_of_datasets1 <- list("df" = df1, "date_frame" = data_frame2) write.xlsx(list_of_datasets1, file = "writeXLSX1.xlsx") #

readxl::read_xls returns “libxls error: Unable to open file”

。_饼干妹妹 提交于 2021-02-08 14:16:40
问题 I have multiple .xls (~100MB) files from which I would like to load multiple sheets (from each) into R as a dataframe. I have tried various functions, such as xlsx::xlsx2 and XLConnect::readWorksheetFromFile , both of which always run for a very long time (>15 mins) and never finish and I have to force-quit RStudio to keep working. I also tried gdata::read.xls , which does finish, but it takes more than 3 minutes per one sheet and it cannot extract multiple sheets at once (which would be very

readxl::read_xls returns “libxls error: Unable to open file”

北城以北 提交于 2021-02-08 14:12:34
问题 I have multiple .xls (~100MB) files from which I would like to load multiple sheets (from each) into R as a dataframe. I have tried various functions, such as xlsx::xlsx2 and XLConnect::readWorksheetFromFile , both of which always run for a very long time (>15 mins) and never finish and I have to force-quit RStudio to keep working. I also tried gdata::read.xls , which does finish, but it takes more than 3 minutes per one sheet and it cannot extract multiple sheets at once (which would be very

Forwarding arguments in a function with purrr::map_df

一曲冷凌霜 提交于 2021-02-08 04:28:06
问题 I am trying to create a function that reads in all sheets in an excel workbook using readxl::read_excel and binds them into a single data frame, and allows me to pass through additional arguments to read_excel . I can do the first part fine, but not the second part. library(magrittr) # example excel workbook with multiple sheets path <- readxl::readxl_example("datasets.xlsx") # function with simple forwarding read_all <- function(path, ...) { path %>% readxl::excel_sheets() %>% rlang::set

Import multiple sheets from excel spreadsheet into r

谁说我不能喝 提交于 2021-02-05 11:49:58
问题 I want to import multiple sheets, selected by a common string in the sheet name, from a single .xlsx file and concatenate them into single data frame. For example, if I have an excel file ('data.xlsx') with worksheets named samples1, samples2, samples3, controls1, controls2, controls3. I want to make a list of the worksheet names, such as: sheet_list <- lapply(excel_sheets('data.xlsx'), read_excel, path = 'data.xlsx') Then, I want to import all sheets that contain 'samples' in the name and

RStudio read.xl working directory error

[亡魂溺海] 提交于 2021-01-28 03:23:35
问题 Hi guys I'm having difficulty loading .xlsx into RStudio - I'm not sure why RStudio can't see the file. Am I specifying the path for read_excel() wrong? Any ideas? Pretty new at R. Thanks! Windows 10 (64-bit) Version 0.99.491 & Version 0.99.840 read.xl 0.1.0 getwd() [1] "C:/Users/user/Documents/Work" read_excel(system.file("C:/Users/user/Documents/Work/Data.xlsx")) Error: '' does not exist in current working directory ('C:/Users/user/Documents/Work') 回答1: The results of the system.file

How to read multiple .xls files in r?

半腔热情 提交于 2020-08-12 00:18:46
问题 I have 18 files(.xls) in list and I want to read them in one go Here is my codes below: filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") df.list=lapply(filenames, function(x) read_excel(file = x,sheetIndex = 1,as.data.frame = TRUE,header = TRUE)) it did not work Could you please tell me what I have done wrong and how I should do it? 回答1: Can you simply try a loop? filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") for (i in 1:length(filenames) { assign(paste0("file_"

How to read multiple .xls files in r?

一世执手 提交于 2020-08-12 00:09:42
问题 I have 18 files(.xls) in list and I want to read them in one go Here is my codes below: filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") df.list=lapply(filenames, function(x) read_excel(file = x,sheetIndex = 1,as.data.frame = TRUE,header = TRUE)) it did not work Could you please tell me what I have done wrong and how I should do it? 回答1: Can you simply try a loop? filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") for (i in 1:length(filenames) { assign(paste0("file_"

How to read multiple .xls files in r?

試著忘記壹切 提交于 2020-08-12 00:06:50
问题 I have 18 files(.xls) in list and I want to read them in one go Here is my codes below: filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") df.list=lapply(filenames, function(x) read_excel(file = x,sheetIndex = 1,as.data.frame = TRUE,header = TRUE)) it did not work Could you please tell me what I have done wrong and how I should do it? 回答1: Can you simply try a loop? filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") for (i in 1:length(filenames) { assign(paste0("file_"

How to read multiple .xls files in r?

杀马特。学长 韩版系。学妹 提交于 2020-08-12 00:05:47
问题 I have 18 files(.xls) in list and I want to read them in one go Here is my codes below: filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") df.list=lapply(filenames, function(x) read_excel(file = x,sheetIndex = 1,as.data.frame = TRUE,header = TRUE)) it did not work Could you please tell me what I have done wrong and how I should do it? 回答1: Can you simply try a loop? filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif") for (i in 1:length(filenames) { assign(paste0("file_"