2
votes

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
It’s pretty unreasonable to make somebody work on a computer that is lacking the necessary tools, and the rights to install those tools. If at all possible, I would strive to change that situation instead of finding hacky workarounds. You will sooner or later be tripped up by the lack of Rtools. (Notably, on a non-Windows computer no admin rights are needed to set up R properly. Windows might need them.)Konrad Rudolph
You preach to the choir! I am also quite done with the laptop I got from my uni, but currently lack the financial power to get a new laptop :( Oh well, I seem to for now have found a workaround version -.-SCW

1 Answers

1
votes

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.