Get data out of excel and into R with readxl
2015-04-16 08:44
513 查看
(This article was first published on RStudio Blog, and kindly contributed to
R-bloggers)
I’m pleased to announced that the first version of readxl is now available on CRAN. Readxl makes it easy to get tabular data out of excel. It:
Supports both the legacy
libxls C library, which abstracts away many of the complexities of the underlying binary format. To parse
RapidXML C++ library.
Has no external dependencies so it’s easy to use on all platforms.
Re-encodes non-ASCII characters to UTF-8.
Loads datetimes into POSIXct columns. Both Windows (1900) and Mac (1904) date specifications are processed correctly.
Blank columns are automatically dropped.
Returns output with class
dplyr you’ll get an enhanced print method (i.e. you’ll see just the first ten rows, not the first 10,000!).
You can install it by running:
There’s not really much to say about how to use it:
You can see the documentation for more info on the
development version, and if that doesn’t work,
file an issue.
R-bloggers)
I’m pleased to announced that the first version of readxl is now available on CRAN. Readxl makes it easy to get tabular data out of excel. It:
Supports both the legacy
.xlsformat and the modern xml-based
.xlsxformat.
.xlssupport is made possible the with
libxls C library, which abstracts away many of the complexities of the underlying binary format. To parse
.xlsx, we use the insanely fast
RapidXML C++ library.
Has no external dependencies so it’s easy to use on all platforms.
Re-encodes non-ASCII characters to UTF-8.
Loads datetimes into POSIXct columns. Both Windows (1900) and Mac (1904) date specifications are processed correctly.
Blank columns are automatically dropped.
Returns output with class
c("tbl_df", "tbl", "data.frame")so if you also use
dplyr you’ll get an enhanced print method (i.e. you’ll see just the first ten rows, not the first 10,000!).
You can install it by running:
install.packages("readxl")
There’s not really much to say about how to use it:
library(readxl) # Use a excel file included in the package sample <- system.file("extdata", "datasets.xlsx", package = "readxl") # Read by position head(read_excel(sample, 2)) #> mpg cyl disp hp drat wt qsec vs am gear carb #> 1 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 #> 2 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 #> 3 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 #> 4 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 #> 5 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 #> 6 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 # Or by name: excel_sheets(sample) #> [1] "iris" "mtcars" "chickwts" "quakes" head(read_excel(sample, "mtcars")) #> mpg cyl disp hp drat wt qsec vs am gear carb #> 1 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 #> 2 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 #> 3 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 #> 4 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 #> 5 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 #> 6 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
You can see the documentation for more info on the
col_names,
col_typesand
naarguments. Readxl is still under active development. If you have problems loading a dataset, please try the
development version, and if that doesn’t work,
file an issue.
相关文章推荐
- Read excel and put cell data into HashMap
- Read and write excel file with format by pandas and xlwt libraries of python
- When does MySQL data get loaded in and out of cache?
- Read data from excel into the object of DataSet.
- [Android] Use Jsoup to grab the web data and process the data with string.indexOf()
- How to read out WhatsApp messages with Tasker and react on their content in real time
- Problems with System.OutOfMemoryException At System.String.GetStringForStringBuilder in 32-Bit Managed Solutions
- Dump data into MySQL from Excel with PHP
- Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
- [Angular] Get started with data binding and SPA
- Struggling trying to get cookie out of response with HttpClient in .net 4.5
- Caused by: java.lang.OutOfMemoryError: Failed to allocate a 29433932 byte allocation with 14683576 free bytes and 14MB
- Get Remote Machines Last Boot Time From A List Of Machines And Write To Excel - 如何获得远程主机的启动时间
- How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
- Investigation report of MSSQL data read and write performance
- Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -
- A simple of Using XML Data Source type and Querying a Web Service with Reporting Services 2008
- And with Li Na out ahead of time
- Dynamics AX 2009: Business Intelligence – How Data Flows into AX SSRS Reports and Excel
- Read a Text File with VBA in Excel, and Write the Text to a Spreadsheet