How to read multiple .xlsx and generate multimple data frames in R?

Captain Nemo

I want to read three different files in xlsx and save them in three different dataframes called excel1, excel2 and excel3. How can I do that? I think it should be something like this:

files = list.files(pattern='[.]xlsx') #There are three files.

for (i in 1:files){
    "excel" + i =read.xlsx(files[i])
}
digEmAll

I suggest you to use a list instead of creating 3 variables in the current workspace:

dfList <- list()
for (i in 1:files){
    dfList[[paste0("excel",i)]] <- read.xlsx(files[i])
}

Then you can access to them in this way :

dfList$excel1
dfList$excel2
dfList$excel3

or :

dfList[[1]]
dfList[[2]]
dfList[[3]]

But, if you really really want to create new variables, you can use assign function :

for (i in 1:files){
    assign(paste0("excel",i), read.xlsx(files[i]))
}
# now excel1, excel2, excel3 variables exist...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Read multiple xlsx files with multiple sheets into one R data frame

From Dev

How to read variable number of files and then combine the data frames in R?

From Dev

how to extract columns in R to make multiple data frames?

From Dev

How to calculate mean and Sd for multiple data frames in R

From Dev

how to extract columns in R to make multiple data frames?

From Dev

How to generate multiple frames of using stylus?

From Dev

Read in a file that contains multimple "CLOB" formatted data fields

From Dev

data type with read.xlsx in R

From Dev

how to create data frames in r

From Dev

Using a loop to create multiple data frames in R

From Java

merge multiple data.frames [r]

From Dev

Same function over multiple data frames in R

From Dev

Search multiple fields in two data Frames in R

From Dev

stacked bar chart in r for multiple data frames

From Dev

R manipulating multiple data frames using a lapply

From Dev

Naming variables in multiple data frames in R

From Dev

How to read data from xlsx in perl

From Dev

How to read and get data from excel .xlsx

From Dev

How to read data from xlsx in perl

From Dev

How to read multiple xlsx file in R using loop with specific rows and columns

From Dev

Generate permutations between values of different data frames in R

From Dev

How to join multiple data frames using dplyr?

From Dev

How to create heatmap from multiple data frames

From Dev

Read from an Excel spreadsheet, and rename multiple folders with data from XLSX

From Dev

Reading horizontal (row-based) data from xlsx files into R data frames

From Dev

How to import multiple xlsx sheets in R

From Dev

How to generate NA in a list of data frames with unequal rows

From Dev

R - subtracting multiple columns from multiple columns with 2 data frames

From Dev

How to merge multiple data.frames and sum and average columns at the same time in R

Related Related

  1. 1

    Read multiple xlsx files with multiple sheets into one R data frame

  2. 2

    How to read variable number of files and then combine the data frames in R?

  3. 3

    how to extract columns in R to make multiple data frames?

  4. 4

    How to calculate mean and Sd for multiple data frames in R

  5. 5

    how to extract columns in R to make multiple data frames?

  6. 6

    How to generate multiple frames of using stylus?

  7. 7

    Read in a file that contains multimple "CLOB" formatted data fields

  8. 8

    data type with read.xlsx in R

  9. 9

    how to create data frames in r

  10. 10

    Using a loop to create multiple data frames in R

  11. 11

    merge multiple data.frames [r]

  12. 12

    Same function over multiple data frames in R

  13. 13

    Search multiple fields in two data Frames in R

  14. 14

    stacked bar chart in r for multiple data frames

  15. 15

    R manipulating multiple data frames using a lapply

  16. 16

    Naming variables in multiple data frames in R

  17. 17

    How to read data from xlsx in perl

  18. 18

    How to read and get data from excel .xlsx

  19. 19

    How to read data from xlsx in perl

  20. 20

    How to read multiple xlsx file in R using loop with specific rows and columns

  21. 21

    Generate permutations between values of different data frames in R

  22. 22

    How to join multiple data frames using dplyr?

  23. 23

    How to create heatmap from multiple data frames

  24. 24

    Read from an Excel spreadsheet, and rename multiple folders with data from XLSX

  25. 25

    Reading horizontal (row-based) data from xlsx files into R data frames

  26. 26

    How to import multiple xlsx sheets in R

  27. 27

    How to generate NA in a list of data frames with unequal rows

  28. 28

    R - subtracting multiple columns from multiple columns with 2 data frames

  29. 29

    How to merge multiple data.frames and sum and average columns at the same time in R

HotTag

Archive