Major update, big improvement.
This commit is contained in:
@@ -94,3 +94,157 @@
|
||||
## TOT[lineNumber]<-content
|
||||
## writeLines(TOT,file)
|
||||
## }
|
||||
|
||||
|
||||
###Old solution for path joins, now I use file.path() function
|
||||
## if(is.null(inputLoc)){
|
||||
## inputLoc<- "./"
|
||||
## } else {
|
||||
## file.path(inputLoc,"")
|
||||
## }
|
||||
## inp <- unlist(strsplit(inputLoc,"")) #This is the charactervector of the given imput location
|
||||
|
||||
## if(inp[length(inp)]!="/"){
|
||||
## inp<-c(inp,"/")
|
||||
## inputLoc <- paste(inp,collapse = "")
|
||||
## rm(inp)
|
||||
## }# If inp not ends in / paste one at the end, then make a string, that will be the new inputLoc
|
||||
|
||||
## ##Example: "a/b/c ==> a/b/c/"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(is.null(epcInput)){
|
||||
epcflag=TRUE
|
||||
epcInput[1] <- paste0(inputLoc,inputParser(string=" EPC file name",fileName=iniFiles[[1]],counter=1,value=TRUE))
|
||||
epcInput[2] <- paste0(inputLoc,inputParser(string=" EPC file name",fileName=iniFiles[[2]],counter=1,value=TRUE))
|
||||
} else {
|
||||
iniFiles[[1]][grep(" EPC file name",iniFiles[[1]])]<-paste(epcInput[1],"\t EPC file name",sep="")
|
||||
|
||||
if(length(epcInput)==2){
|
||||
iniFiles[[2]][grep(" EPC file name",iniFiles[[2]])]<-paste(epcInput[2],"\t EPC file name",sep="")
|
||||
}
|
||||
}
|
||||
|
||||
if(is.null(metInput)){
|
||||
metflag=TRUE
|
||||
metInput[1] <- unlist(strsplit(grep(" met file name",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
metInput[2] <- unlist(strsplit(grep(" met file name",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep(" met file name",iniFiles[[1]])]<-paste(metInput[1],"\t met file name",sep="")
|
||||
|
||||
if(length(metInput)==2){
|
||||
iniFiles[[2]][grep(" met file name",iniFiles[[2]])]<-paste(metInput[2],"\t met file name",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(CO2Input)){
|
||||
CO2flag=TRUE
|
||||
CO2Input[1] <- unlist(strsplit(grep(" CO2 file",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
CO2Input[2] <- unlist(strsplit(grep(" CO2 file",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep(" CO2 file",iniFiles[[1]])]<-paste(CO2Input[1],"\t CO2 file",sep="")
|
||||
|
||||
if(length(CO2Input)==2){
|
||||
iniFiles[[2]][grep(" CO2 file",iniFiles[[2]])]<-paste(CO2Input[2],"\t CO2 file",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(nitInput)){
|
||||
nitflag=TRUE
|
||||
nitInput[1] <- unlist(strsplit(grep("N-dep file",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
nitInput[2] <- unlist(strsplit(grep("N-dep file",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("N-dep file",iniFiles[[1]])]<-paste(nitInput[1],"N-dep file",sep="N-dep file")
|
||||
|
||||
if(length(epcInput)==2){
|
||||
iniFiles[[2]][grep("N-dep file",iniFiles[[2]])]<-paste(nitInput[2],"N-dep file",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(thinInput)){
|
||||
thinflag=TRUE
|
||||
thinInput[1] <- unlist(strsplit(grep("do THINNING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
thinInput[2] <- unlist(strsplit(grep("do THINNING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do THINNING",iniFiles[[1]])]<-paste(thinInput[1],"do THINNING",sep="")
|
||||
|
||||
if(length(thinInput)==2){
|
||||
iniFiles[[2]][grep("do THINNING",iniFiles[[2]])]<-paste(thinInput[2],"do THINNING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(plantInput)){
|
||||
plantflag=TRUE
|
||||
plantInput[1] <- unlist(strsplit(grep("do PLANTING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
plantInput[2] <- unlist(strsplit(grep("do PLANTING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do PLANTING",iniFiles[[1]])]<-paste(plantInput[1],"do PLANTING",sep="")
|
||||
|
||||
if(length(plantInput)==2){
|
||||
iniFiles[[2]][grep("do PLANTING",iniFiles[[2]])]<-paste(plantInput[2],"do PLANTING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(mowInput)){
|
||||
mowflag=TRUE
|
||||
mowInput[1] <- unlist(strsplit(grep("do MOWING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
mowInput[2] <- unlist(strsplit(grep("do MOWING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do MOWING",iniFiles[[1]])]<-paste(mowInput[1],"do MOWING",sep="")
|
||||
|
||||
if(length(mowInput)==2){
|
||||
iniFiles[[2]][grep("do MOWING",iniFiles[[2]])]<-paste(mowInput[2],"do MOWING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(grazInput)){
|
||||
grazflag=TRUE
|
||||
grazInput[1] <- unlist(strsplit(grep("do GRAZING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
grazInput[2] <- unlist(strsplit(grep("do GRAZING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do GRAZING",iniFiles[[1]])]<-paste(grazInput[1],"do GRAZING",sep="")
|
||||
|
||||
if(length(grazInput)==2){
|
||||
iniFiles[[2]][grep("do GRAZING",iniFiles[[2]])]<-paste(grazInput[2],"do GRAZING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(harvInput)){
|
||||
harvflag=TRUE
|
||||
harvInput[1] <- unlist(strsplit(grep("do HARVESTING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
harvInput[2] <- unlist(strsplit(grep("do HARVESTING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do HARVESTING",iniFiles[[1]])]<-paste(harvInput[1],"do HARVESTING",sep="")
|
||||
|
||||
if(length(harvInput)==2){
|
||||
iniFiles[[2]][grep("do HARVESTING",iniFiles[[2]])]<-paste(harvInput[2],"do HARVESTING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(plougInput)){
|
||||
plougflag=TRUE
|
||||
plougInput[1] <- unlist(strsplit(grep("do PLOUGHING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
plougInput[2] <- unlist(strsplit(grep("do PLOUGHING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do PLOUGHING",iniFiles[[1]])]<-paste(plougInput[1],"do PLOUGHING",sep="")
|
||||
|
||||
if(length(plougInput)==2){
|
||||
iniFiles[[2]][grep("do PLOUGHING",iniFiles[[2]])]<-paste(plougInput[2],"do PLOUGHING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(fertInput)){
|
||||
fertflag=TRUE
|
||||
fertInput[1] <- unlist(strsplit(grep("do FERTILIZING",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
fertInput[2] <- unlist(strsplit(grep("do FERTILIZING",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do FERTILIZING",iniFiles[[1]])]<-paste(fertInput[1],"do FERTILIZING",sep="")
|
||||
|
||||
if(length(fertInput)==2){
|
||||
iniFiles[[2]][grep("do FERTILIZING",iniFiles[[2]])]<-paste(fertInput[2],"do FERTILIZING",sep="")
|
||||
}}
|
||||
|
||||
if(is.null(irrInput)){
|
||||
irrflag=TRUE
|
||||
irrInput[1] <- unlist(strsplit(grep("do IRRIGATION",iniFiles[[1]],value=TRUE),"[\ \t]"))[1]
|
||||
irrInput[2] <- unlist(strsplit(grep("do IRRIGATION",iniFiles[[2]],value=TRUE),"[\ \t]"))[1]
|
||||
} else {
|
||||
iniFiles[[1]][grep("do IRRIGATION",iniFiles[[1]])]<-paste(irrInput[1],"do IRRIGATION",sep="")
|
||||
|
||||
if(length(irrInput)==2){
|
||||
iniFiles[[2]][grep("do IRRIGATION",iniFiles[[2]])]<-paste(irrInput[2],"do IRRIGATION",sep="")
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user