example_dt = data.table(lon = 1:3, month = 4:6, prec = 7:9)
file_name = tempfile()
dt_to_netcdf(dt = example_dt, nc_out = file_name,
vars = "prec", units = "mm",
dim_vars = c("lon","month"), dim_var_units = c("degree longitude","month"))
Run the code above in your browser using DataLab