How to import xlsx (2010) file into R 2.15.0

we have over 7000 excel data files for .xlsx (2010). my version of R is R 2.15.0. if I perform a manual operation to convert xlsx to xlx, .cvs or txt., it will spend more time on this.

+4
source share
2 answers

I did not use XLSconnect, but my students used the xlsx package. Then either the read.xlsx function or read.xlsx2 will be read in the xls sheet. This package has options for reading and writing xls format and can read and write specific sheets in a spreadsheet and in certain regions.

The only official guide I gave my students (sophomore biology) to use this package is that the table should be "well-formed." (all elements are data non-formulas, the first line is the name of the variable in lower case without any letters without letters, and lines 2 - ## have data for each variable. If this is a record, than all elements for one record are in one line). It does not have * .xls to be so strict, but I wanted a minimum of problems for students when they read their data files.

+1
source

The read.xls function in the gdata package will read the xlsx and xls files in R I often use this.

It looks like you have a lot of Excel files to work with, here is what I am doing to get a large number of these files (both xlsx and xls ) in R :

Setting up work directly with the location of Excel files

 setwd("F:\\ address of folder with all my Excel files") 

List all files in the working directory

 MyFiles <- list.files() 

Check list

 MyFiles 

Makeke list containing all the data from the xls and xlsx files contained in the working directory. This is similar to the batch data import function.

 library(gdata) Mylist <- lapply(MyFiles, read.xls) 

Make sure that it reads all the files in the folder if some Excel files are corrupted, etc. If the result is FALSE , a problem occurs.

 identical(length(MyFiles), length(Mylist)) 

Then I continue to work with sapply , etc. to perform functions according to data in files.

+1
source

Source: https://habr.com/ru/post/1411305/


All Articles