Skip to content
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

Closed
BarkleyBG opened this issue Jul 5, 2017 · 13 comments
Closed

Comments

@BarkleyBG
Copy link

Hi there, I'm having problems with printing huxtables

> 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

> as_hux(mtcars[1:4, 1:4])     %>% ##doesn't print well
+     huxtable::add_rownames(colname = 'Car name') %>% 
+     huxtable::add_colnames()
Error in data.frame(row = rep(1:nrow(ht), ncol(ht)), col = rep(1:ncol(ht),  : 
  arguments imply differing number of rows: 40, 30

Here I try to re-create the MWE. You'll see that the ht_cars object seems to behave well when passed to the dim, str, and class functions, but not when asked to print it.

> ht_cars <- as_hux(mtcars[1:4, 1:4]) 
> 
> dim(ht_cars)
[1] 4 4
> str(ht_cars)
Classes ‘huxtable’ and 'data.frame':	4 obs. of  4 variables:
 $ mpg : num  21 21 22.8 21.4
 $ cyl : num  6 6 4 6
 $ disp: num  160 160 108 258
 $ hp  : num  110 110 93 110
 - attr(*, "align")= chr [1:4, 1:4] "left" "left" "left" "left" ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "valign")= chr [1:4, 1:4] "top" "top" "top" "top" ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "rowspan")= num [1:4, 1:4] 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "colspan")= num [1:4, 1:4] 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "background_color")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "text_color")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "top_border")= num [1:4, 1:4] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "left_border")= num [1:4, 1:4] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "right_border")= num [1:4, 1:4] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "bottom_border")= num [1:4, 1:4] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "top_border_color")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "left_border_color")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "right_border_color")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "bottom_border_color")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "top_padding")= num [1:4, 1:4] 4 4 4 4 4 4 4 4 4 4 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "left_padding")= num [1:4, 1:4] 4 4 4 4 4 4 4 4 4 4 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "right_padding")= num [1:4, 1:4] 4 4 4 4 4 4 4 4 4 4 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "bottom_padding")= num [1:4, 1:4] 4 4 4 4 4 4 4 4 4 4 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "wrap")= logi [1:4, 1:4] FALSE FALSE FALSE FALSE FALSE FALSE ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "escape_contents")= logi [1:4, 1:4] TRUE TRUE TRUE TRUE TRUE TRUE ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "na_string")= chr [1:4, 1:4] "" "" "" "" ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "bold")= logi [1:4, 1:4] FALSE FALSE FALSE FALSE FALSE FALSE ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "italic")= logi [1:4, 1:4] FALSE FALSE FALSE FALSE FALSE FALSE ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "font_size")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "rotation")= num [1:4, 1:4] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "font")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "pad_decimal")= logi [1:4, 1:4] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "col_width")= Named logi  NA NA NA NA
  ..- attr(*, "names")= chr  "mpg" "cyl" "disp" "hp"
 - attr(*, "row_height")= Named logi  NA NA NA NA
  ..- attr(*, "names")= chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
 - attr(*, "width")= num 0.5
 - attr(*, "height")= logi NA
 - attr(*, "position")= chr "center"
 - attr(*, "caption")= logi NA
 - attr(*, "caption_pos")= chr "top"
 - attr(*, "tabular_environment")= chr "tabularx"
 - attr(*, "label")= logi NA
 - attr(*, "number_format")=List of 16
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..$ : chr "%5.2f"
  ..- attr(*, "dim")= int  4 4
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive"
  .. ..$ : chr  "mpg" "cyl" "disp" "hp"
> class(ht_cars)
[1] "huxtable"   "data.frame"

However printing doesn't work here either

> 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
> print(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
> print_screen(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
> print_latex(ht_cars)
Error: 'sanitize' is not an exported object from 'namespace:xtable'
> print_html(ht_cars)
Error: 'sanitize' is not an exported object from 'namespace:xtable'

Session info below. Thanks a lot!

> 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    
[5] datasets  methods   base     

other attached packages:
[1] huxtable_0.3.0  dplyr_0.5.0    
[3] purrr_0.2.2     readr_1.0.0    
[5] tidyr_0.6.1     tibble_1.3.0   
[7] ggplot2_2.2.1   tidyverse_1.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.4      knitr_1.15.1    
 [3] magrittr_1.5     munsell_0.4.2   
 [5] xtable_1.7-4     colorspace_1.2-6
 [7] R6_2.1.2         stringr_1.2.0   
 [9] highr_0.5.1      plyr_1.8.4      
[11] tools_3.2.3      grid_3.2.3      
[13] gtable_0.2.0     DBI_0.5-1       
[15] htmltools_0.3.5  lazyeval_0.2.0  
[17] assertthat_0.1   digest_0.6.12   
[19] rprojroot_1.2    crayon_1.3.1    
[21] memoise_1.0.0    evaluate_0.10   
[23] rmarkdown_1.3    stringi_1.1.2   
[25] scales_0.4.1     backports_1.0.4 
@hughjonesd
Copy link
Owner

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?

@BarkleyBG
Copy link
Author

I updated xtable to version 1.8-2

> library(xtable)
Warning message:
package ‘xtable’ was built under R version 3.2.5 
> library(huxtable)

Attaching package: ‘huxtable’

The following objects are masked from ‘package:xtable’:

    align, align<-, caption,
    caption<-, label, label<-

The following object is masked from ‘package:stats’:

    filter

There's some masking going on. I'm also loading the tidyverse.

> library(tidyverse)
package �tidyverse� was built under R version 3.2.5Loading tidyverse: ggplot2
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
package �ggplot2� was built under R version 3.2.5package �tibble� was built under R version 3.2.5package �tidyr� was built under R version 3.2.5package �readr� was built under R version 3.2.5package �purrr� was built under R version 3.2.5package �dplyr� was built under R version 3.2.5Conflicts with tidy packages ----------------------------------------------------------
add_rownames(): dplyr, huxtable
every():        purrr, huxtable
filter():       dplyr, huxtable, stats
lag():          dplyr, stats

But the problem persists

> 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

Should I install_github() from the last commit for huxtable?

@hughjonesd
Copy link
Owner

Hmm, tricky. Could you try the same code in a fresh session having only loaded library(huxtable)? Thanks.

@BarkleyBG
Copy link
Author

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?

@hughjonesd
Copy link
Owner

hughjonesd commented Jul 7, 2017 via email

@BarkleyBG
Copy link
Author

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!

@BarkleyBG
Copy link
Author

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?

@hughjonesd
Copy link
Owner

hughjonesd commented Jul 17, 2017 via email

@BarkleyBG
Copy link
Author

BarkleyBG commented Aug 13, 2017

Hi David,

I can't seem to find the bug. (Side note - does dplyr have an add_colnames() function? I can't find it in my version or on the github site.)

I used str(obj) in different stages of debugging to see what was going on. Here's the traceback:

#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

In steps 1-5, str(x) or str(ht) shows that the huxtable has

attr(*, "number_format")=List of 16

However, in step 6, then the str(ht) returns

attr(*, "number_format")=List of 20

Since the error is that the original data.frame has 16 cells, and the error is arguments imply differing number of rows: 24, 20, I'm thinking there's something in here that is causing everything.

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!

@hughjonesd
Copy link
Owner

If you had a chance to check this bug in the latest 1.0.0 version I'd be most grateful!

@BarkleyBG
Copy link
Author

BarkleyBG commented Oct 8, 2017 via email

@BarkleyBG
Copy link
Author

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.

> 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
> as_hux(mtcars[1:4, 1:4])
  21.00   6.00    160.00   110.00  
  21.00   6.00    160.00   110.00  
  22.80   4.00    108.00   93.00   
  21.40   6.00    258.00   110.00  

Column names: mpg, cyl, disp, hp

^^ success!!

> library(dplyr)

Attaching package: ‘dplyr’

The following object is masked from ‘package:huxtable’:

    add_rownames

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> hux(
+     Employee     = c('John Smith', 'Jane Doe', 'David Hugh-Jones'), 
+     Salary       = c(50000, 50000, 40000),
+     add_colnames = TRUE
+ )                               %>% 
+     set_bold(1, 1:2, TRUE)          %>% 
+     set_bottom_border(1, 1:2, 1)    %>%
+     set_align(1:4, 2, 'right')      %>%
+     set_right_padding(10)           %>%
+     set_left_padding(10)            %>% 
+     set_caption('Employee table')
        Employee table         
  Employee             Salary  
───────────────────────────────
  John Smith         50000.00  
  Jane Doe           50000.00  
  David Hugh-Jones   40000.00  

Column names: Employee, Salary

^^^ continued success!!

sessioninfo fwiw:

> sessionInfo()
R version 3.3.0 (2016-05-03)
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    
[5] datasets  methods   base     

other attached packages:
[1] dplyr_0.7.3.9000 huxtable_1.0.0  

loaded via a namespace (and not attached):
 [1] magrittr_1.5     assertthat_0.2.0
 [3] R6_2.2.2         tools_3.3.0     
 [5] bindrcpp_0.2     glue_1.1.1      
 [7] tibble_1.3.4     crayon_1.3.2    
 [9] Rcpp_0.12.12     knitr_1.17      
[11] pkgconfig_2.0.1  rlang_0.1.2     
[13] bindr_0.1 

@hughjonesd
Copy link
Owner

That's my suspicion too. Thanks for the bug report and testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants