-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors: arguments imply differing number of rows, and exporting sanitize #13
Comments
The MWE works for me. Could you update xtable to the latest version? Also, could you do ??rowspan and ??colspan, and check if any other packages are defining these functions? |
I updated xtable to version 1.8-2
There's some masking going on. I'm also loading the tidyverse.
But the problem persists
Should I |
Hmm, tricky. Could you try the same code in a fresh session having only loaded |
I opened a new Rproject in a new directory, and the same issue persists.
I don't know why the packages are included in |
I don't think the set of packages is very unusual, though it's not quite
the same as mine.
I think the only thing to do at this point is `options(error=recover)` and
debug why this call, which is in the unexported `display_cells` function,
is failing!
David
…On 6 July 2017 at 19:17, Brian G. Barkley ***@***.***> wrote:
I opened a new Rproject in a new directory, and the same issue persists.
> mtcars[1:4, 1:4]
mpg cyl disp hp
Mazda RX4 21.0 6 160 110
Mazda RX4 Wag 21.0 6 160 110
Datsun 710 22.8 4 108 93
Hornet 4 Drive 21.4 6 258 110
> library(huxtable)
Attaching package: ‘huxtable’
The following object is masked from ‘package:stats’:
filter
> ht_cars <- as_hux(mtcars[1:4, 1:4])
> ht_cars
Error in data.frame(row = rep(1:nrow(ht), ncol(ht)), col = rep(1:ncol(ht), :
arguments imply differing number of rows: 24, 20
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] huxtable_0.3.0
loaded via a namespace (and not attached):
[1] magrittr_1.5 R6_2.1.2 assertthat_0.1
[4] DBI_0.5-1 tools_3.2.3 dplyr_0.5.0
[7] tibble_1.3.0 memoise_1.0.0 crayon_1.3.1
[10] Rcpp_0.12.4 knitr_1.15.1 digest_0.6.12
I don't know why the packages are included in loaded via a namespace (and
not attached), is that unusual/potentially an issue?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFjJ9xwDFSHb2Cd5aTPFzH2uT8xbZUBmks5sLSTLgaJpZM4ONvmU>
.
|
Ok, David, I'll try to do that later in the week. Feel free to bump this thread if you don't hear from me! |
I haven't pinpointed it, but I have some suggestions. Starting with MRE,
I jump in to
This stop call happens because condition following the
I think the issue is that
This leads me to believe that the
This is beyond my understanding, but I would expect these to all be of equal length. Perhaps noteworthy is the following:
Hope this helps. Any ideas? |
Hi Brian,
Yes, this is the problem. For some reason the call to display_cells is
passing in an `ht` object where rowspan and colspan are wrong. So, could
you investigate `to_screen.huxtable`? One possibility is that the call to
`add_colnames` in that function is doing something weird... I wonder if it
s calling dplyr::add_colnames instead of the huxtable version.
David
…On 14 July 2017 at 18:09, Brian G. Barkley ***@***.***> wrote:
I haven't pinpointed it, but I have some suggestions. Starting with MRE,
options(error=recover)
ht_cars <- as_hux(mtcars[1:4, 1:4])
ht_cars
#Error in data.frame(row = rep(1:nrow(ht), ncol(ht)), col = rep(1:ncol(ht), :
# arguments imply differing number of rows: 8, 6
#
#Enter a frame number, or 0 to exit
#
#1: function (x, ...)
#UseMethod("print")(x)
#2: print.huxtable(x)
#3: meth(x, ...)
#4: cat(to_screen(ht, ...))
#5: to_screen(ht, ...)
#6: to_screen.huxtable(ht, ...)
#7: display_cells(ht, all = FALSE)
#8: data.frame(row = rep(1:nrow(ht), ncol(ht)), col = rep(1:ncol(ht), each = nrow(ht)), rowspan = as.vector
I jump in to 8. data.frame. the error comes from lines 94-123, or the
stop call from line 121-122, i think
nr <- max(nrows)
for (i in seq_len(n)[nrows < nr]) {
xi <- vlist[[i]]
if (nrows[i] > 0L && (nr%%nrows[i] == 0L)) {
xi <- unclass(xi)
fixed <- TRUE
for (j in seq_along(xi)) {
xi1 <- xi[[j]]
if (is.vector(xi1) || is.factor(xi1))
xi[[j]] <- rep(xi1, length.out = nr)
else if (is.character(xi1) && inherits(xi1,
"AsIs"))
xi[[j]] <- structure(rep(xi1, length.out = nr),
class = class(xi1))
else if (inherits(xi1, "Date") || inherits(xi1,
"POSIXct"))
xi[[j]] <- rep(xi1, length.out = nr)
else {
fixed <- FALSE
break
}
}
if (fixed) {
vlist[[i]] <- xi
next
}
}
stop(gettextf("arguments imply differing number of rows: %s",
paste(unique(nrows), collapse = ", ")), domain = NA)
}
This stop call happens because condition following the if on line 97
returns false:
(nrows[i] > 0L && (nr%%nrows[i] == 0L))
I think the issue is that nrows equals c(24, 24, 20, 20) and so nr <-
max(nrows) equals 24, so the if condition returns false.
nrows equals the above due to the behavior in the for loop from lines 56
to 93. In particular, the if statement just below the loop is false, so
the else statement is executed:
for (i in seq_len(n)) {
xi <- if (is.character(x[[i]]) || is.list(x[[i]]))
as.data.frame(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors)
else as.data.frame(x[[i]], optional = TRUE)
This leads me to believe that the x list is perhaps where the error
originates. Here's the original call to x:
x <- list(...)
x
# $row
# [1] 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6
#
#$col
#[1] 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4
#
#$rowspan
# [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#
#$colspan
# [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
This is beyond my understanding, but I would expect these to all be of
equal length.
Perhaps noteworthy is the following:
Browse[1]> object
$row
rep(1:nrow(ht), ncol(ht))
$col
rep(1:ncol(ht), each = nrow(ht))
$rowspan
as.vector(new_rowspan)
$colspan
as.vector(new_colspan)
Browse[1]> mirn
[1] TRUE
Browse[1]> mrn
[1] TRUE
Hope this helps. Any ideas?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFjJ9y71ovmXxFubujmlteIvbPFvrydZks5sN6DlgaJpZM4ONvmU>
.
|
Hi David, I can't seem to find the bug. (Side note - does I used
In steps 1-5,
However, in step 6, then the
Since the error is that the original data.frame has 16 cells, and the error is I'm not at all sure why that would change in this step, but I couldn't dig any deeper. I hope this helps though! |
If you had a chance to check this bug in the latest 1.0.0 version I'd be most grateful! |
I sure will! I saw the tweet announcement and it's already on my todo list.
Congrats on v1!
|
Hey, it works now! Awesome!!! Thanks! (example below) Just curious, did you change anything in the imports field in the description? I'm wondering if all this was a namespace issue.
^^ success!!
^^^ continued success!! sessioninfo fwiw:
|
That's my suspicion too. Thanks for the bug report and testing. |
Hi there, I'm having problems with printing huxtables
Here I try to re-create the MWE. You'll see that the
ht_cars
object seems to behave well when passed to thedim
,str
, andclass
functions, but not when asked to print it.However printing doesn't work here either
Session info below. Thanks a lot!
The text was updated successfully, but these errors were encountered: