R write dataframe to excel without admin rights

≯℡__Kan透↙ 提交于 2021-02-10 09:28:11

问题


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.

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")

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

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

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/45188571/r-write-dataframe-to-excel-without-admin-rights

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!