Skip to content

Commit

Permalink
More robust loops
Browse files Browse the repository at this point in the history
Do not use 1:length()
  • Loading branch information
eibanez committed Jan 29, 2015
1 parent a4c9a98 commit ca30d1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions R/plexos_open.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@ plexos_open <- function(folders = ".", names = folders) {
"Rerun process_folder() to avoid problems.",
call. = FALSE)
} else {
# Compare
comp <- integer(length(conf$rplexos))
for (i in 1:length(conf$rplexos))
comp[i] <- compareVersion(this.vers, conf$rplexos[i])
# Compare to installed version
comp <- sapply(conf$rplexos, compareVersion, this.vers)

if (any(comp == -1)) {
if (any(comp > 0)) {
warning("File(s) processed with a newer version of rplexos. ",
"Update rplexos or rerun process_folder() to avoid problems.",
call. = FALSE)
} else if (any(comp == 1)) {
warning("File(s) processed with an old version of rplexos. ",
} else if (any(comp < 0)) {
warning("File(s) processed with an older version of rplexos. ",
"Rerun process_folder() to avoid problems.",
call. = FALSE)
}
Expand Down
2 changes: 1 addition & 1 deletion R/process_solution.R
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ add_extra_tables <- function(db) {
dbGetQuery(db$con, sql)

# Fix time stamps in t_period_X (summary data)
for (i in 1:length(column.times)) {
for (i in seq_along(column.times)) {
sql <- sprintf("INSERT INTO temp_period_%s
SELECT %s, %s, min(interval_id), min(correct_time) time
FROM temp_phase_%s
Expand Down

0 comments on commit ca30d1d

Please sign in to comment.