Installing ncdf in R

NB a prerequisite is that the netcdf libraries are already installed.

$ mkdir -p ~/.R/libs
$ export R_LIBS=~/.R/libs
$ echo 'R_LIBS=~/.R/libs/'
$ export R_LIBS=~/.R/libs/
$ echo 'R_LIBS=~/.R/libs/'
$ echo 'R_LIBS=~/.R/libs/' >> ~/.Renviron
#Download the ncdf package from CRAN
#All this can be done in a temporary area ... (?)
$ tar xvzf ncdf_1.6.tar.gz
$ R CMD INSTALL ncdf
$ history

Making use of ncdf in R

$ R
> library(ncdf)
> nd = open.ncdf("interpolations.nc")
> x=get.var.ncdf(nd,"Original")
> y=get.var.ncdf(nd,"Interpolations")
> v <- array(x, length(x))
> w <- array(y, length(y))
> xx=x[!is.na(x) & x>=0 & x < 100]
> yy=y[!is.na(x) & x>=0 & x < 100]
> yyy=yy[!is.na(xx) & xx>=0 & xx < 100]
> plot(xxx,yyy)
> cor(xxx,yyy)
> ff <- lm(yyy ~ xxx)
> z=ff$coefficients[1]*xxx + ff$coefficients[2]