Now changemulline function works for lists

This commit is contained in:
hollorol 2018-02-19 13:59:00 +01:00
parent 20deb229c2
commit 47cb43fb46

View File

@ -7,16 +7,21 @@
#' @keywords internal #' @keywords internal
changemulline <- function(filename,calibrationpar,contents){ changemulline <- function(filename,calibrationpar,contents){
#This is the function which is capable change multiple specific lines to other using their row numbers. ##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. ##The function uses the previous changspecline function to operate.
##From now changespecline is in the forarcheologist file, because its no longer needed ##From now changespecline is in the forarcheologist file, because its no longer needed
varnum <- length(calibrationpar) varnum <- length(calibrationpar)
if(length(contents)!=varnum) contents <- as.list(contents)
{ if(length(contents)!=varnum)
stop(" number of the values is not the same as the number of the changed parameters") {
} 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)
} }
readedFile = readLines(filename,-1)
for(i in 1:varnum){
readedFile[calibrationpar[i]] <- paste(contents[[i]],collapse = " ")
}
writeLines(unlist(readedFile),filename)
}