Skip to content

Commit 926819b

Browse files
committed
more missingness checks
1 parent 03bdc26 commit 926819b

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: wrapr
22
Type: Package
33
Title: Wrap R Tools for Debugging and Parametric Programming
44
Version: 2.0.5
5-
Date: 2020-11-04
5+
Date: 2020-11-12
66
Authors@R: c(
77
person("John", "Mount", email = "[email protected]", role = c("aut", "cre")),
88
person("Nina", "Zumel", email = "[email protected]", role = c("aut")),

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# wrapr 2.0.5 2020-11-04
2+
# wrapr 2.0.5 2020-11-12
33

44
* More ... checks.
55
* Better error message for extra comman in unpack.

R/cf.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ to_vector <- function(lst) {
7575
#'
7676
build_frame <- function(..., cf_eval_environment = parent.frame()) {
7777
v <- as.list(substitute(list(...)))
78+
lengths <- vapply(
79+
v,
80+
function(vi) {nchar(paste(as.character(vi), collapse = ''))},
81+
numeric(1))
82+
if(any(lengths <= 0)) {
83+
stop("empty entry, this is often caused by an extra comma")
84+
}
7885
v <- lapply(seqi(2, length(v)), function(i) {v[[i]]})
7986
force(cf_eval_environment)
8087
lv <- length(v)
@@ -382,6 +389,13 @@ qchar_frame <- function(...) {
382389
if(lv<1) {
383390
return(data.frame())
384391
}
392+
lengths <- vapply(
393+
v,
394+
function(vi) {nchar(paste(as.character(vi), collapse = ''))},
395+
numeric(1))
396+
if(any(lengths <= 0)) {
397+
stop("empty entry, this is often caused by an extra comma")
398+
}
385399
# inspect input
386400
cls <- vapply(v, class, character(1))
387401
if(length(setdiff(cls, c("call", "character", "name", "numeric", "integer", "logical", "factor")))>0) {
@@ -419,7 +433,7 @@ qchar_frame <- function(...) {
419433
ncell <- length(vu)
420434
nrow <- ncell/ncol
421435
if(abs(nrow - round(nrow))>0.1) {
422-
stop("wrapr::qchar_frame confused as to cell count")
436+
stop("wrapr::qchar_frame confused as to cell count (this can be an extra comma or mis-placed separator)")
423437
}
424438
fr <- as.data.frame(matrix(data = vu[-seq_len(ncol)],
425439
ncol=ncol,

0 commit comments

Comments
 (0)