Skip to content
Snippets Groups Projects
Commit 7899a777 authored by Svajunas Plunge's avatar Svajunas Plunge Committed by Christoph Schürz
Browse files

Fixes to add_kill_op

parent 8dfc5bd0
No related branches found
No related tags found
No related merge requests found
^.*\.Rproj$ ^.*\.Rproj$
^\.Rproj\.user$ ^\.Rproj\.user$
test.R test*
\ No newline at end of file \ No newline at end of file
...@@ -27,4 +27,4 @@ vignettes/*.pdf ...@@ -27,4 +27,4 @@ vignettes/*.pdf
# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
rsconnect/ rsconnect/
.Rproj.user .Rproj.user
test.R test*
\ No newline at end of file \ No newline at end of file
# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand
export(add_kill_op)
export(get_hru_id_by_attribute) export(get_hru_id_by_attribute)
export(plot_climate_annual) export(plot_climate_annual)
export(plot_hru_pw_day) export(plot_hru_pw_day)
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
add_kill_op <- function(project_path){ add_kill_op <- function(project_path){
mgt_sch <- read_lines(paste0(project_path,'/management.sch'), lazy = FALSE) mgt_sch <- read_lines(paste0(project_path,'/management.sch'), lazy = FALSE)
write_lines(mgt_sch, paste0(project_path,'/management_bak.sch'))
l <- 0 l <- 0
while(length(grep("hvkl", mgt_sch)) != 0){ while(length(grep("hvkl", mgt_sch)) != 0){
i <- grep("hvkl", mgt_sch)[1] i <- grep("hvkl", mgt_sch)[1]
...@@ -26,8 +25,9 @@ add_kill_op <- function(project_path){ ...@@ -26,8 +25,9 @@ add_kill_op <- function(project_path){
l <- l+1 l <- l+1
} }
if(l > 0){ if(l > 0){
file.copy(paste0(project_path,'/management.sch'), paste0(project_path,'/management_bak.sch'))
write_lines(mgt_sch, paste0(project_path,'/management.sch')) write_lines(mgt_sch, paste0(project_path,'/management.sch'))
return(paste0(l, " lines were updated in 'management.sch'. Original file is backed up in 'management_bak.sch'.")) return(paste0(l, " lines were updated (`hvkl` changed to `harv`) and same number added (with `kill` operations) in 'management.sch'. Original file is backed up in 'management_bak.sch'."))
} else { } else {
return("No `hvkl` operations exist in 'management.sch'. File was not changed.") return("No `hvkl` operations exist in 'management.sch'. File was not changed.")
} }
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helper.R
\name{add_kill_op}
\alias{add_kill_op}
\title{Replace hvkl operations with harv + kill}
\usage{
add_kill_op(project_path)
}
\arguments{
\item{project_path}{Character string, path to the SWAT+ project folder
(i.e. TxtInOut).}
}
\value{
updated management.sch file
}
\description{
Replace hvkl operations with harv + kill
}
\examples{
\dontrun{
add_kill_op('path_to_your_model')
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helper.R
\name{insert_line_at}
\alias{insert_line_at}
\title{Insert line into character with multiple lines}
\usage{
insert_line_at(dat, txt, insert_after)
}
\arguments{
\item{dat}{character with multiple lines}
\item{txt}{character line to be inserted}
\item{insert_after}{numeric for line number after, which to insert txt}
}
\value{
character with multiple lines with inserted new lines
}
\description{
Insert line into character with multiple lines
}
\keyword{internal}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment