写dataframe到excel没有管理权限

时间:2022-04-17 22:51:07

I am a complete newby to R, so bear with me if the answer is obvious. I work on a laptop that is not owned by me and I thus have no admin rights whatsoever besides the original installation that the administrator had done for me. I assume that the lack of admin rights is the reason for me not to be able to write to an excel file. See an example below. The original dataframe is merged from bibliographic databases. Error codes are the same. Writing the original data file as a text file did work, but some rows did not turn out properly once opened in excel. Tried on another computer with xlsx package, everthing worked fine and I had not problems with weird rows. That's what I want.

我对R完全陌生,所以如果答案很明显,请耐心等待。我在一台笔记本电脑上工作,它不是我所有的,因此除了管理员为我做的原始安装之外,我没有任何管理权限。我认为缺少管理权限是我不能写excel文件的原因。请参阅下面的一个例子。原始的dataframe是从书目数据库中合并而来的。错误代码是一样的。将原始数据文件编写为文本文件是可行的,但有些行在excel中打开后却不能正常显示。在另一台装有xlsx软件包的电脑上试用,一切正常,我对奇怪的行没有问题。这就是我想要的。

Name1= c(1,2,3,4,5)
Name2= c("Africa", "Europe", "America", "Asia", "Australia")
data = data.frame(Name1, Name2)

library(openxlsx)
write.xlsx(data, file = "C:/Users/ISSL16002/Desktop/R/Test.xlsx")

Error: zipping up workbook failed. Please make sure Rtools is installed or a zip application is available to R. Try installr::install.rtools() on Windows. If the "Rtools\bin" directory does not appear in Sys.getenv("PATH") please add it to the system PATH or set this within the R session with Sys.setenv("R_ZIPCMD" = "path/to/zip.exe")

错误:压缩工作簿失败。请确保安装了Rtools或可以使用zip应用程序R.在Windows上尝试安装:install.rtools()。如果“Rtools\bin”目录没有出现在Sys.getenv(“PATH”)中,请将其添加到系统路径中,或者在与Sys的R会话中设置。setenv(“R_ZIPCMD”=“路径/ / zip.exe”)

library(xlsx)

Loading required package: rJava Error: package or namespace load failed for ‘rJava’: .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the Registry Error: package ‘rJava’ could not be loaded

加载所需的包:rJava错误:“rJava”的包或名称空间加载失败:.onLoad在“rJava”的loadNamespace()中失败,细节:调用:fun(libname, pkgname)错误:JAVA_HOME不能从注册表错误中确定:包'rJava'不能加载。

library(rJava)

Error: package or namespace load failed for ‘rJava’: .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the Registry

错误:“rJava”的包或名称空间装载失败:“rJava”的loadNamespace()中的.onLoad失败,详细信息:call: fun(libname, pkgname)错误:无法从注册表中确定JAVA_HOME

Anyone an idea what I can do, i.e. is there another package possible? I don't care for the formatting functions etc, just need a proper excel file. Please keep in mind that I hardly "speak" R, so I a) hope the explanation was understandable and b) I'll be able to understand answers - so laymen's terms if possible. Many thanks, Ikke

有人知道我能做什么吗,也就是说,还有别的方案吗?我不关心格式等功能,只需要一个合适的excel文件。请记住,我几乎不会“说”R,所以我希望a)希望解释是可以理解的,b)我将能够理解答案——如果可能的话,外行的术语。许多谢谢,Ikke

1 个解决方案

#1


1  

Wath you can do is to export as csv. You won't need a certain package therefore.

你可以做的是导出为csv。因此,您不需要特定的包。

write.csv(data, "C:/Users/ISSL16002/Desktop/R/Test.csv")

You can open this with excel without problems and, if necessary, save it then as an xlsx.

您可以在没有问题的情况下使用excel打开它,如果需要,可以将其保存为xlsx。

#1


1  

Wath you can do is to export as csv. You won't need a certain package therefore.

你可以做的是导出为csv。因此,您不需要特定的包。

write.csv(data, "C:/Users/ISSL16002/Desktop/R/Test.csv")

You can open this with excel without problems and, if necessary, save it then as an xlsx.

您可以在没有问题的情况下使用excel打开它,如果需要,可以将其保存为xlsx。