Skip to content

Commit

Permalink
fetch_data: fixed bug with missing evid and mdv
Browse files Browse the repository at this point in the history
  • Loading branch information
bguiastr committed Jun 20, 2017
1 parent 6c80311 commit e27a363
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions R/fetch_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,20 @@ data_opt <- function(problem = NULL,
# Create shortcut functions on the fly to filter observations
only_obs <- function(xpdb, problem, quiet) {
mdv_var <- xp_var(xpdb, problem, type = c('evid', 'mdv'))$col[1]
string <- c('Filtering data by ', mdv_var, ' == 0')
fun <- function(x) {}
body(fun) <- bquote({
msg(.(string), .(quiet))
x[x[, .(mdv_var)] == 0, ]
})
if (!is.null(mdv_var)) {
string <- c('Filtering data by ', mdv_var, ' == 0')
body(fun) <- bquote({
msg(.(string), .(quiet))
x[x[, .(mdv_var)] == 0, ]
})
} else {
string <- c('No `evid` or `mdv` variable available to filter the data.')
body(fun) <- bquote({
msg(.(string), .(quiet))
x
})
}
fun
}

Expand Down

0 comments on commit e27a363

Please sign in to comment.