checkr icon indicating copy to clipboard operation
checkr copied to clipboard

Checkr breaks with lapply

Open peterhurford opened this issue 9 years ago • 0 comments

> colon_split_to_list <- checkr::ensure(
+   pre = list(string %is% simple_string, grepl(": ", string)),
+   post = list(result %is% list, length(result) == 1),
+   function(string) {
+     colon_split <- strsplit(string, ": ")[[1]]
+     setNames(list(colon_split[[2]]), colon_split[[1]])
+   })
> lapply(list("arg 1: val 1", "arg 2: val 2"), colon_split_to_list)
Error in eval(expr, envir, enclos) : '...' used in an incorrect context
> packageVersion("checkr")
[1] ‘0.0.4.9005’
> colon_split_to_list("arg: value")
$arg
[1] "value"

> lapply(list("arg 1: val 1", "arg 2: val 2"), colon_split_to_list)
Error in eval(expr, envir, enclos) : '...' used in an incorrect context
> lapply(list("arg 1: val 1", "arg 2: val 2"), function(s) colon_split_to_list(s))
[[1]]
[[1]]$`arg 1`
[1] "val 1"


[[2]]
[[2]]$`arg 2`
[1] "val 2"

peterhurford avatar Apr 22 '16 16:04 peterhurford