小樱知识 > 生活常识r语言读取excel数据(r语言对excel数据的分析)

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

提问时间:2022-03-10 14:12:18来源:小樱知识网


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

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

以上内容就是为大家推荐的r语言读取excel数据(r语言对excel数据的分析)最佳回答,如果还想搜索其他问题,请收藏本网站或点击搜索更多问题

内容来源于网络仅供参考
二维码

扫一扫关注我们

版权声明:所有来源标注为小樱知识网www.xiaoyin02.com的内容版权均为本站所有,若您需要引用、转载,只需要注明来源及原文链接即可。

本文标题:r语言读取excel数据(r语言对excel数据的分析)

本文地址:https://www.xiaoyin02.com/shcs/95905.html

相关文章