r - 在R中读取xlsx文件
问题描述
我用过这段代码:
library(openxlsx)
fileUrl <- "http://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FDATA.gov_NGAP.xlsx"
d <- download.file(fileUrl,destfile = "C:/Users/skoma/Desktop/data/dat.xlsx")
data <- read.xlsx("dat.xlsx")
这是出现的错误:
文件中的错误(con,“r”):无效的“描述”参数另外:警告消息:在解压缩(xlsxFile,exdir = xmlDir)中:“unz”代码中的内部错误
解决方案
首先,您不应该传递download.file
给变量 ( d
)。然后,你想下载那个特别的 xlsx 作为二进制文件来工作。所以试试这个
download.file(fileUrl,destfile = "C:/Users/skoma/Desktop/data/dat.xlsx",mode = "wb")
哪里mode = "wb"
是二进制。这个对我有用。
推荐阅读
- c - 在示例之间复制文件时出现 IAR Workbench 错误 [Li005]
- kubernetes - Kubernetes:为特定部署配置专用节点组 + 为其他所有内容配置默认节点组
- r - 使用viridis在ggplot2中的气泡图图例颜色
- http - 反向代理零指针
- angular - 如何将 Ngx-bootstrap typeahead 中的自动完成数据绑定到输入字段
- python - 从列中提取数字以在 Pandas 中创建新列
- r - R散点图可视化:如何将自定义多个基因着色成散点图?
- c# - c# VS 2019 Xamarin:从嵌入图像的代码中设置图像源的问题
- python - 如何在python中将3D数组转换为2D?
- bash - 带有 if [[ 的 bash 脚本!-f path_to_files ]]