How to export R results to Excel

Dear @andresrcs
Thanks for the reply.
I got this error when run your suggested codes:
write.xlsx(as.data.frame(result$r), file = "results.xlsx")
Error in write.xlsx(as.data.frame(result$r), file = "results.xlsx") :
could not find function "write.xlsx"