In my data analysis in R
I sometimes output data to Excel files using write.xlsx
. These files need to be password-protected, and currently I am doing this by opening the unprotected file using Excel, and then adding a password using File - Protect Workbook - Encrypt with Password
.
Is there a way to do this directly in R
so that I don't have to open the Excel file and manually add the password? (I want to password-protect the whole workbook, not just a single sheet.)
From the xlsx manual, you can set the password in the password argument: