简体   繁体   English

使用任何库从 R 读取 Excel 文件

[英]Using any Library to Read Excel files from R

I have R installed in a usb stick (since I'm using work computer and don't have Admin access to install software), and so far I've been having to resort to read.csv() since I can't use any library to read excel files.我已将 R 安装在 usb 棒中(因为我使用的是工作计算机并且没有管理员权限来安装软件),到目前为止我不得不求助于 read.csv() 因为我无法使用任何用于读取 excel 文件的库。 For example, XLConnect gives the problem of:例如,XLConnect 给出的问题是:

>Error: package or namespace load failed for ‘XLConnect’:
>> .onLoad failed in loadNamespace() for 'rJava', details:<br>
>>  call: inDL(x, as.logical(local), as.logical(now), ...)<br>
>>  error: unable to load shared object 'D:/R/R-4.0.2/library/rJava/libs/x64/rJava.dll':<br>
>  LoadLibrary failure:  %1 is not a valid Win32 application.<br>
>In addition: Warning message:
>package ‘XLConnect’ was built under R version 4.0.3

It seems that these libraries (readxl, xlsx, or XLConnect) are failing because they don't know where I have Java installed.这些库(readxl、xlsx 或 XLConnect)似乎失败了,因为他们不知道我在哪里安装了 Java。 So, I also did this:所以,我也这样做了:

Sys.setenv(JAVA_HOME='C:\Program Files (x86)\Java\jre1.8.0_131\bin') Sys.setenv(JAVA_HOME='C:\Program Files (x86)\Java\jre1.8.0_131\bin')

but, to no avail.但是,无济于事。 (that advice I got it from https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/ ) (我从https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from得到的建议-注册表/

If someone knows how to read excel files using R from a memory stick - I would really appreciate if they can point north to me.如果有人知道如何使用 memory 棒上的 R 读取 excel 文件 - 如果他们能向北指向我,我将不胜感激。

btw, this is the error when loading xlsx library:顺便说一句,这是加载 xlsx 库时的错误:

> library(xlsx)
>Error: package or namespace load failed for ‘xlsx’:
>> .onLoad failed in loadNamespace() for 'rJava', details:<br>
>>  call: inDL(x, as.logical(local), as.logical(now), ...)<br>
>>  error: unable to load shared object 'D:/R/R-4.0.2/library/rJava/libs/x64/rJava.dll':<br>
>>  LoadLibrary failure:  %1 is not a valid Win32 application.
<br>
>In addition: Warning message:<br>
>package ‘xlsx’ was built under R version 4.0.3 

and this is the error when trying to read an excel file with readxl (no problem when loading):这是尝试使用 readxl 读取 excel 文件时的错误(加载时没有问题):

>*Error in loadNamespace(name) : there is no package called ‘cli’*

This is it, this did it:就是这样,做到了:

"You may want to check out this posting: stackoverflow.com/questions/29254067/…" – SteveM 16 hours “您可能想查看此帖子:stackoverflow.com/questions/29254067/...” – SteveM 16 小时

Thank you kind stranger.谢谢好心的陌生人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM