0
install.packages('xlsx')     
library(xlsx) 
require("xlsx")
write.xlsx(data, "data.xlsx")

output: error 1:

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/user/AppData/Local/R/win-library/4.2’ (as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib /4.2/xlsx_0.6.5.zip'
Content type 'application/zip' length 374502 bytes (365 KB)
downloaded 365 KB

Error2 :

package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
In addition: Warning message:
package ‘xlsx’ was built under R version 4.2.2

I have received error both in install packages and library attachment as I mentioned in error1 and error 2

AminRana
  • 1
  • 1
  • 1
    You need to install Rtools and get it working before you can use the `xlsx` package, and I think Java too. This is addressed in the [Common Problems section of the package webpage](https://github.com/colearendt/xlsx#common-problems). There are certainly other options, I believe [writexl](https://cran.r-project.org/web/packages/writexl/index.html) doesn't have any special requirements. – Gregor Thomas Jan 31 '23 at 18:59
  • 2
    If Java is going to be an issue for you, I suggest you instead try one of `openxlsx` or `writexl` packages. – r2evans Jan 31 '23 at 18:59

0 Answers0