From 47cb43fb46ae131df24f36551aa2c9a2ef474bb6 Mon Sep 17 00:00:00 2001 From: hollorol Date: Mon, 19 Feb 2018 13:59:00 +0100 Subject: [PATCH] Now changemulline function works for lists --- RBBGCMuso/R/changeMuso.R | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/RBBGCMuso/R/changeMuso.R b/RBBGCMuso/R/changeMuso.R index 03cbf2b..11f7f61 100644 --- a/RBBGCMuso/R/changeMuso.R +++ b/RBBGCMuso/R/changeMuso.R @@ -7,16 +7,21 @@ #' @keywords internal changemulline <- function(filename,calibrationpar,contents){ - #This is the function which is capable change multiple specific lines to other using their row numbers. - #The function uses the previous changspecline function to operate. - ##From now changespecline is in the forarcheologist file, because its no longer needed - varnum <- length(calibrationpar) - if(length(contents)!=varnum) - { - stop(" number of the values is not the same as the number of the changed parameters") - } - - TOT=readLines(filename,-1) - TOT[calibrationpar]<-contents - writeLines(TOT,filename) + ##This is the function which is capable change multiple specific lines to other using their row numbers. + ##The function uses the previous changspecline function to operate. + ##From now changespecline is in the forarcheologist file, because its no longer needed + varnum <- length(calibrationpar) + contents <- as.list(contents) + if(length(contents)!=varnum) + { + stop(" number of the values is not the same as the number of the changed parameters") } + + readedFile = readLines(filename,-1) + + for(i in 1:varnum){ + readedFile[calibrationpar[i]] <- paste(contents[[i]],collapse = " ") + } + + writeLines(unlist(readedFile),filename) +}