r语言读取excel数据(r语言对excel数据的分析)

R语言中有很多读取Excel文件的Package,如RODBC、xlsx、gdata、xlsReadWrite等,但都有很多缺点(依赖Java,依赖操作系统,列数限制、效率等等),而下面要介绍的两个包可以完美地解决这些问题,现在小编就来说说关于r语言读取excel数据?下面内容希望能帮助到你,我们来一起看看吧!

r语言读取excel数据(r语言对excel数据的分析)

r语言读取excel数据

R语言中有很多读取Excel文件的Package,如RODBC、xlsx、gdata、xlsReadWrite等,但都有很多缺点(依赖Java,依赖操作系统,列数限制、效率等等),而下面要介绍的两个包可以完美地解决这些问题。

知识点

  • openxlsx: simplifies the the process of writing and styling Excel xlsx files from R and removes the dependency on Java.
  • readxl: Read Excel Files. Works on Windows, Mac and Linux without external dependencies.

包安装

install.packages("openxlsx")install.packages("readxl")

Read Excel file

# readxl 自带的excel文件xls_file <- readxl::readxl_example("datasets.xls")xlsx_file <- readxl::readxl_example("datasets.xlsx")readxl::read_xls(xls_file)readxl::read_xlsx(xlsx_file)openxlsx::read.xlsx(xlsx_file)

Write Excel file

xlsx_file <- readxl::readxl_example("datasets.xlsx")df <- openxlsx::read.xlsx(xlsx_file)openxlsx::write.xlsx(df, file = "datasets.xlsx")

Edit Excel file

openxlsx 具有以下功能:

  • 操作 WorkSheet
  • 操作 Cell & Style
  • 插入图片
  • 函数
  • 设置行高、列宽
  • 格式化等等

Reference

  • http://ycphs.github.io/openxlsx/index.html
  • http://readxl.tidyverse.org/

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页