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

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

上一篇:小智能手机有哪些 迷你智能小手机新款)

下一篇:bootstrap遮罩层 bootstrap底部导航栏)


蚂蚁钢琴网 2008-2025 www.somall.com.cn 皖ICP备2023010105号 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!点击这里给我发消息
违法和不良信息24小时举报热线:18056540210 钢琴调律 钢琴调音 钢琴调律价格 网速测试 宽带网速测试