RSAGA provides access to geocomputation capabilities of SAGA GIS from within R environment. Having SAGA GIS installed is a (quite obvious) pre-requirement to use RSAGA.
In Linux x64 sometimes additional preparations are needed. In Linux SAGA as well as other software that would like to use SAGA modules usually searches for them in /usr/lib/saga, but if your Linux is x64, they usually will be located in /usr/lib64/saga. Of course you may set up proper environmental variables, but the most lazy and overall-effective way is just to add symbolic link to /usr/lib64/saga (or whatever a correct path is) from /usr/lib/saga:
:~> sudo ln -s /usr/lib64/saga /usr/lib/saga
Now no app should miss these modules.
Let's to set up an environment in R.
# set up rsaga environment:
> work_env <- rsaga.env()
$workspace  "."
$cmd  "saga_cmd"
$path  "/usr/bin"
$modules  "/usr/lib/saga"
$version  "2.0.8"
Note that in this case modules appeared to be located in /usr/lib when they are actually in /usr/lib64. Thanks to the symbolic link, we don't have to provide RSAGA with the real location. If you need to set up detailed environmental parameters run:
> work_env <- rsaga.env(workspace='path_to_your_folder',
+ path = '/usr/bin',
+ modules = '/usr/lib64/saga')
It's time to get the list of available libraries (sets of modules):
 "contrib_a_perego" "docs_html"
 "docs_pdf" "garden_3d_viewer"
 "garden_webservices" "geostatistics_grid"
...and so on
Each library has a number of modules inside. And we will use modules, not libraries in geoprocessing. Let's get a list of modules inside one of the library:
code name interactive
1 0 Simple Filter FALSE
2 1 Gaussian Filter FALSE
3 2 Laplacian Filter FALSE
4 3 Multi Direction Lee Filter FALSE
5 4 User Defined Filter FALSE
6 5 Filter Clumps FALSE
7 6 Majority Filter FALSE
8 7 DTM Filter (slope-based) FALSE
9 8 Morphological Filter FALSE
10 9 Rank Filter FALSE
In column 'name' we have a module name; column 'interactive' indicates whether this module is interactive, and column 'code' contains the code to be used when the module is called. Now we would like for example to know how to use module 'DTM Filter (slope-based)':
> rsaga.get.usage('grid_filter', 7)
Usage: saga_cmd -INPUT <str> [-RADIUS <num>] [-TERRAINSLOPE <str>] [-STDDEV] -GROUND <str> -NONGROUND <str>
-INPUT:<str> Grid to filter
-RADIUS:<num> Search Radius
-TERRAINSLOPE:<str> Approx. Terrain Slope
-STDDEV Use Confidence Interval
-GROUND:<str> Bare Earth
-NONGROUND:<str> Removed Objects
library path: /usr/lib/saga
library name: libgrid_filter
module name : DTM Filter (slope-based)
Now we have detailed information about parameters we have to provide as well as data types that these parameters must have. But before we proceed, we have to prepare the data. RSAGA will accept only grid formats for processing, so one have to convert data to suitable format:
Finally we are ready to execute our first RSAGA geoprocessing command:
>rsaga.geoprocessor('grid_filter', module = 7,
+ env = work_env,
+ param = list(INPUT = 'lidar.sgrd',
+ RADIUS = 20,
+ TERRAINSLOPE = 0,
+ STDDEV = T,
+ GROUND = 'ground',
+ NONGROUND = 'non_ground')
Instead of conclusion
RSAGA has a certain degree of inconvenience in usage. It only works with files in .srgd format and both input and output have to be physically stored on your hard drive. So it is better to use it [instead of the SAGA itself] only for routine tasks.