Wednesday, February 23, 2011

To debug R code

Either :
* put the command browser() : will stop where the command "browser" was called
* or call the function debug : debug(name_function_to_debug) : will stop at the start of the script
* options(error=recover)

Type "Q" to exit the browser. Type "n" to execute the next line. Type "c" or ENTER to continue running and exit the function.

Monday, February 14, 2011

Installing RNetCDF (ncdf) in R

Taken from https://stat.ethz.ch/pipermail/r-help/2008-March/157089.html
This is ubuntu 10.4.

sudo apt-get install libudunits2-0 libudunits2-dev
sudo apt-get install libnetcdf4 libnetcdf-dev

Then in R :
install.packages("RNetCDF",configure.args="--with-netcdf-include=/usr/include")

Note : A regular install is unable to find netcdf.h, giving the error below. Use rather the install.packages command given above.

checking for netcdf.h... no
configure: error: netcdf header netcdf.h not found
ERROR: configuration failed for package ‘ncdf’