“terra” can read and write most file formats, via the GDAL library. For netCDF files, use writeCDF
GDAL
writeCDF