[GRASS-SVN] r66853 - grass-addons/grass7/vector/v.class.mlR
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 16 09:33:43 PST 2015
Author: mlennert
Date: 2015-11-16 09:33:43 -0800 (Mon, 16 Nov 2015)
New Revision: 66853
Modified:
grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py
Log:
This is a much more elegant way of making sure the install can happen in the home directory
Modified: grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py
===================================================================
--- grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py 2015-11-16 16:52:06 UTC (rev 66852)
+++ grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py 2015-11-16 17:33:43 UTC (rev 66853)
@@ -148,23 +148,18 @@
r_file = open(r_commands, 'w')
- create_dir = 'homeR = paste(Sys.getenv("HOME"), "/R/personal", sep="")\n'
- create_dir += "if(!file.exists(homeR)) {dir.create(homeR, recursive=TRUE)}\n"
- create_dir += ".libPaths(homeR)"
- r_file.write(create_dir)
- r_file.write("\n")
- install = "if(!is.element('e1071', installed.packages()[,1])) "
- install += "{cat('\n\nInstalling e1071 package from CRAN into\n')\n"
- install += "cat(homeR)\n"
- install += "cat('\n')\n"
+ install = "if(!is.element('e1071', installed.packages()[,1])){\n"
+ install += "cat('\\n\\nInstalling e1071 package from CRAN\n')\n"
+ install += "if(!file.exists(Sys.getenv('R_LIBS_USER'))){\n"
+ install += "dir.create(Sys.getenv('R_LIBS_USER'), recursive=TRUE)\n"
+ install += ".libPaths(Sys.getenv('R_LIBS_USER'))}\n"
install += "install.packages('e1071', "
- install += "repos='https://mirror.ibcp.fr/pub/CRAN/', "
- install += "lib = homeR)}"
+ install += "repos='https://mirror.ibcp.fr/pub/CRAN/')}"
r_file.write(install)
r_file.write("\n")
r_file.write('library(e1071)')
r_file.write("\n")
- r_file.write("cat('\nRunning R to tune and apply model...\n')")
+ r_file.write("cat('\\nRunning R to tune and apply model...\\n')")
r_file.write("\n")
r_file.write('features<-read.csv("%s", sep="|", header=TRUE)' % feature_vars)
r_file.write("\n")
@@ -244,13 +239,13 @@
r_file.write(model_string)
r_file.write("\n")
- r_file.write("cat('\nTuning (or model) summary: \n\n')")
+ r_file.write("cat('\\nTuning (or model) summary: \\n\\n')")
r_file.write("\n")
r_file.write("cat('Kernel used: ')")
r_file.write("\n")
- r_file.write("cat('%s\n')" % kernel)
+ r_file.write("cat('%s\\n')" % kernel)
r_file.write("\n")
- install += "cat('\n')"
+ install += "cat('\\n')"
r_file.write("\n")
r_file.write("summary(model)")
r_file.write("\n")
More information about the grass-commit
mailing list