Hi all,
I am trying to extract the column names of 20 datasets in my directory. Not sure what wrong i am doing here. Can anyone help me
## list the excel file
list_of_excel_files <- list.files(pattern = ".xlsx")
## read all excel file in a single command
for (i in 1:length(list_of_excel_files)) {
# print(list_of_excel_files[1])
filenames <- list_of_excel_files[i]
filenames_data <- read_excel(filenames, skip = 1)
assign(x = filenames, value = filenames_data)
}
## read column names for the above datasets
for (i in 1:length(ls(pattern = "xlsx"))) {
col_names <- ls(pattern = "xlsx")[i]
#print(col_names)
display_colnames <- colnames(col_names)
assign(x = paste0(col_names,"_colnames"), value = display_colnames)
}