Skip to content

Commit

Permalink
Merge pull request #440 from MatMatt/master
Browse files Browse the repository at this point in the history
[sextante] changed R command .libPaths to add and not substitute paths
  • Loading branch information
volaya committed Feb 25, 2013
2 parents 148e7e1 + aa4b291 commit f3fa14c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions python/plugins/sextante/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ def getExportCommands(self):
def getImportCommands(self):
commands = []
# if rgdal is not available, try to install it
# just use US mirror
commands.append('options("repos"="http://cran.us.r-project.org")')
# just use main mirror
commands.append('options("repos"="http://cran.at.r-project.org/")')
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
if not os.path.isdir(rLibDir):
os.mkdir(rLibDir)
commands.append('.libPaths("%s")' % rLibDir )
# .libPaths("%s") substitutes the personal libPath with "%s"! With '.libPaths(c("%s",deflibloc))' it is added without replacing and we can use all installed R packages!
commands.append('deflibloc <- .libPaths()[1]')
commands.append('.libPaths(c("%s",deflibloc))' % rLibDir )
commands.append(
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="%s"))' % rLibDir)
commands.append("library(\"rgdal\")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
##[Example scripts]=group
##Layer = raster
##no_data_value = number 0
##breaks = number 100
##color = string red
##showplots
Layer <- raster(Layer, 1)
NAvalue(Layer) = no_data_value
hist(as.matrix(Layer), breaks=100, xlab = basename(filename(Layer)))
hist(Layer, breaks=breaks,col=color)

0 comments on commit f3fa14c

Please sign in to comment.