R:如何将多个表分成一个而不复制标题行?

我有数以百计的电子表格,在一个文件夹中有成千上万行,需要将它们分组到一个工作表中。 我已经设法做到这一点,但我最终复制了第一行对应的标题,并希望删除这些行,只留下第一行(这应该是一个头)。

我在一个df中合并这些文件的代码是:

setwd("~/Desktop/R studies/base1_rawsheets") #folder with spreadsheets library(readxl) data.files = list.files() df <- readxl::read_excel(data.files[1], sheet=1) #reading the first file of list for (file in data.files[-1]){ newFile <- readxl::read_excel(file, sheet=1) df <- merge(df, newFile, all=T) } 

非常感谢您的帮助!

PS:我使用的代码是从这里的解决scheme改编如何在R编程中读取多个Excel表单?

只需在第一个电子表格中用[-1,]删除每个捕获的xlsx的第一个观察值即可。

 df <- readxl::read_excel(data.files[1], sheet=1) #reading the first file of list for (file in data.files[-1]){ newFile <- readxl::read_excel(file, sheet=1)[-1,] ## Drops the first row df <- merge(df, newFile, all=T) }