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