Combine two epidemiology netcdf files in R


I have 2 netCDF files (each .nc file has 4 variables: Susceptible, Infected, Recovered and Inhabitable. The dimension of each variable is 64 x 88). I would like to merge these 2 files using R into a single netCDF file such that the merged file will stack separately Susceptible from the 2 files, Infected from the 2 files, Recovered from the 2 files and Inhabitable from the 2 files. By "stack separately" I mean to place the arrays one on top of the other. For example Susceptible from file1 is for time 0001 and Susceptible from file2 is for time 0002 etc. There is a free tool called Panoply that let's you create an animation if the netCDF files have a time context for the variables (in my case Susceptible, Infected, Recovered).

Could anyone help me with this please?

Thanks in advance,
Last edited: