[Robast-commits] r647 - in branches/robast-0.9/pkg/RobAStRDA: R inst/AddMaterial/interpolation

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 16 22:15:16 CEST 2013


Author: ruckdeschel
Date: 2013-04-16 22:15:15 +0200 (Tue, 16 Apr 2013)
New Revision: 647

Modified:
   branches/robast-0.9/pkg/RobAStRDA/R/interpolAux.R
   branches/robast-0.9/pkg/RobAStRDA/R/sysdata.rda
   branches/robast-0.9/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R
Log:
RobAStRDA: + remade sysdata.rda after Peter's part of trac ticket #139 (LM-smoothing)
+ fixed a but in .mergeGrid (was: if(ncol(Grid1)==ncol(Grid2)) instead of if(ncol(Grid1)!=ncol(Grid2)) )
+ borrowed code from help.request for interactively checking for overwriting
+ some polishing in interpolation/interpolationscripts.R --- important: use of withSmoothFct = TRUE
  to force interpolators to use smoothed grids
            

Modified: branches/robast-0.9/pkg/RobAStRDA/R/interpolAux.R
===================================================================
--- branches/robast-0.9/pkg/RobAStRDA/R/interpolAux.R	2013-04-16 20:11:48 UTC (rev 646)
+++ branches/robast-0.9/pkg/RobAStRDA/R/interpolAux.R	2013-04-16 20:15:15 UTC (rev 647)
@@ -127,6 +127,12 @@
                            withSmooth = TRUE, df = NULL,
                            gridRestrForSmooth = NULL){
 
+  ## help functions to capture keyboard input taken from help.request
+    no <- function(answer) answer == "n"
+    yes <- function(answer) answer == "y"
+    readMyLine <- function(..., .A. = "(y/n)") readline(paste(paste(strwrap(paste(...)),
+        collapse = "\n"), .A., ""))
+
   ### check whether input is complete
   if(missing(fromFileCSV)) stop("You must specify argument 'fromFileCSV'.")
   if(missing(toFileRDA)) stop("You must specify argument 'toFileRDA'.")
@@ -163,12 +169,11 @@
           if(namPFam %in% namesInterpGrids){
              cat(gettext("There already is a grid for family "),
                  namPFam,".\n",sep="")
-             cat("\n",
-                 gettext("Do you really want to overwrite/merge it (yes=1/no else)?"),"\n",
-                 sep="")
-             ans <- try(scan(what=integer(1)), silent = TRUE)
-             if(is(ans,"try-error")) ans <- 0
-             if(ans==1){
+             ans <- readMyLine(
+             paste("\n",
+                 gettext("Do you really want to overwrite/merge it (y/n)?"),"\n",
+                 sep=""))
+             if(yes(ans)){
                 if(withMerge){
                    gr0 <- .mergeGrid(InterpGrids[[namPFam]]$grid, Grid)
                    InterpGrids[[namPFam]]$grid <- gr0
@@ -217,7 +222,8 @@
 # .mergeGrid merges two grids according to the lines
 ############################################################################
 .mergeGrid <- function(Grid1, Grid2){
-   if(ncol(Grid1)==ncol(Grid2))
+
+   if(ncol(Grid1)!=ncol(Grid2))
       stop("Grids must have the same number of columns")
    Grid <- rbind(Grid1, Grid2)
    on <- order(Grid[,1])

Modified: branches/robast-0.9/pkg/RobAStRDA/R/sysdata.rda
===================================================================
(Binary files differ)

Modified: branches/robast-0.9/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R
===================================================================
--- branches/robast-0.9/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R	2013-04-16 20:11:48 UTC (rev 646)
+++ branches/robast-0.9/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R	2013-04-16 20:15:15 UTC (rev 647)
@@ -15,8 +15,8 @@
 oldwd <- getwd()
 .basepath <- "C:/rtest/RobASt/branches/robast-0.9/pkg"
 .myFolderFrom <- file.path(.basepath,"RobExtremesBuffer")
-myRDA0 <- file.path(.basepath,"RobExtremesBuffer/sysdata0.rda")
-myRDA <- file.path(.basepath,"RobExtremesBuffer/sysdata.rda")
+myRDA0 <- file.path(.basepath,"RobExtremesBuffer/sysdata.rda")
+#myRDA <- file.path(.basepath,"RobExtremesBuffer/sysdata.rda")
 #myRDA0 <- file.path(.basepath,"RobAStRDA/R/sysdata0.rda")
 myRDA <- file.path(.basepath,"RobAStRDA/R/sysdata.rda")
 CSVFiles <- grep("\\.csv$", dir(.myFolderFrom), value=TRUE)
@@ -25,4 +25,4 @@
 .saveGridToRda(CSVFiles, toFileRDA = myRDA0, withMerge = FALSE,
                withPrint = TRUE, withSmooth = TRUE, df = NULL)
 ##
-.computeInterpolators(myRDA0, myRDA)
+.computeInterpolators(myRDA0, myRDA,withSmoothFct = TRUE)



More information about the Robast-commits mailing list