You can use the write.csv()
function from base R for csv and for Excel there are many options, among them the writexl
and openxlsx
packages.
If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.