nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
179 stars 18 forks source link

Pixiedust not rendering table #64

Closed pgensler closed 8 years ago

pgensler commented 8 years ago

Hello I am trying to create a basic table with pixiedust, and I keep on getting this error: Error in UseMethod("arrange") : no applicable method for 'arrange' applied to an object of class "NULL"

Below is my code that I am using. Thanks.

Create Patient Table

playernumber <- c(40,16,34,13,5,9,22) athlete <- c("John Resetti","Tom Nook","K.K Slider","Tortimer Montcillo","Booker Wright","Gayle Puffpants","Wolfgang Puck") height <- c("5-11", "6-4","5-10","6-7","6-10","6-4","6-8") status <- c("B","S","S","S","S","S","B") roster <- data.frame(playernumber,athlete,height, status)

class(roster) roster %>% sprinkle(rows=NULL, cols=NULL, c(2,4), border_color= "#000000")

I think there might be something with magrittr that is not working as well, as it was not finding the pipe operator when I loaded magrittr and dplyr to use it. Session Info: R version 3.3.1 (2016-06-21) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.6 (El Capitan)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] dplyr_0.5.0 magrittr_1.5 pixiedust_0.7.4

loaded via a namespace (and not attached): [1] Rcpp_0.12.5 formatR_1.4 RColorBrewer_1.1-2 plyr_1.8.4
[5] tools_3.3.1 rpart_4.1-10 digest_0.6.9 packrat_0.4.7-1
[9] checkmate_1.8.1 nlme_3.1-128 tibble_1.1 evaluate_0.9
[13] gtable_0.2.0 lattice_0.20-33 psych_1.6.6 Matrix_1.2-6
[17] DBI_0.4-1 parallel_3.3.1 yaml_2.1.13 gridExtra_2.2.1
[21] stringr_1.0.0 knitr_1.13 cluster_2.0.4 grid_3.3.1
[25] nnet_7.3-12 lazyWeave_3.0.1 data.table_1.9.6 R6_2.1.2
[29] survival_2.39-5 foreign_0.8-66 rmarkdown_1.0 latticeExtra_0.6-28 [33] Formula_1.2-1 tidyr_0.5.1 reshape2_1.4.1 ggplot2_2.1.0
[37] backports_1.0.3 Hmisc_3.17-4 scales_0.4.0 htmltools_0.3.5
[41] splines_3.3.1 mnormt_1.5-4 rsconnect_0.4.2.2 assertthat_0.1
[45] colorspace_1.2-6 stringi_1.1.1 acepack_1.3-3.3 lazyeval_0.2.0
[49] munsell_0.4.3 broom_0.4.1 chron_2.3-47

nutterb commented 8 years ago

Before you can sprinkle a table, you need to dust it first.

dust(roster) %>%
  sprinkle([arguments])

I also see in your code an error that I don't think you intended. When you look at the third argument below, you'll see that c(2,4) isn't attached to anything. Did you intend this to be the cols argument.

dust(roster) %>%
    sprinkle(rows=NULL, 
                   cols=NULL, 
                      c(2,4),   # What did you intend this to be?
                      border_color= "#000000")

A working example of code would be the following, which will draw borders around all cells in the second and fourth columns:

dust(roster) %>%
    sprinkle(rows=NULL, 
                   cols=c(2,4),  
                      border_color= "#000000")
pgensler commented 8 years ago

Thanks for the prompt response! I really appreciate it. I wanted to apply a black border to the first two rows of the roster table, but I was unsure where to go to find colors that I could input in. Are there r packages I need to import to work with the colors?

nutterb commented 8 years ago

You aren't required to import any packages to work with colors, but you are certainly free to do so.

You may use any of the colors listed in colors() (displayed in this document )

You may also use any valid rgb specification or any valid HTML specification (such as #000000 for black).

A couple of websites I use when looking for colors are https://en.wikipedia.org/wiki/Web_colors and http://www.w3schools.com/colors/colors_names.asp

If you use RColorBrewer, you can use any of those color codes as well, since brewer.pal returns HTML color codes.

In your specific use case, perhaps the easiest thing to do would be

dust(roster) %>%
    sprinkle(rows = 1:2 
                      border_color= "black")
pgensler commented 8 years ago

Thanks for the response. I think it would help to have reference to the pages you gave me for finding colors, as I had no idea where to even start with the color codes. When do you think you will have the changes for features such as border color implemented in markdown? It would be extremely helpfull for some reports I used to create in excel to have a package that can do that with conditional formatting.

nutterb commented 8 years ago

As far as I know, markdown itself doesn't support border colors. So, unfortunately, there is no way for me to implement it in pixiedust. If markdown ever begins supporting borders, I will be sure to implement it.

If there are R packages that can provide that kind of conditional formatting for Excel, I'd be willing to entertain writing a new engine, but I would need guidance as to which package has the best support. At the moment, the only other engine I plan to support is ReporteRs, and I will resume development on that as soon as I clear a couple other projects off my plate.

pgensler commented 8 years ago

Below are some of the packages that I have seen that has the most support for borders/conditional formatting: rhandsontable (java script library) formattable printr(from the knitr package) condformat

I would guess that rhandsontable probably has the best development so far in terms of features offered, but it really does need some help to make the features more accessible in R. RStudio has been driving for web graphics, so I think this would be a good complement to the resources already in development, like notebooks. You can access some of their current features at the links below: http://jrowen.github.io/rhandsontable/ https://handsontable.com/