According to this question/answer: gridExtra Colour different rows with tableGrob, gridExtra does not have the ability to highlight specific rows in the grid.table.
What then can be done to plot a table with specific row highlighting. Is there a better table package on CRAN?
Is the only solution to build the table up from its component rectangles, lines and labels?
Edit:
The output needs to be an image. I am using rmarkdown and html/TeX rendering of markdown tables are inconsistent, and TeX tables are usually too big for good beamer slides, plus you can't control the size (except using \tiny etc). I'm not at liberty to alter the beamer default file, and so the only real work around is to do tables as images, then you can specify the size etc.
Related
When exporting plots to a .docx with the officer package, a lot of white space is created around the plots.
That way it is using up way to much space in the word document. It would be nice to crop the picture to get rid of the white space around the plot, so it looks more like this:
I don't know (1) if I have to set the dimension/size of the plot when I create the plot or (2) when I export the plot to the .docx with officer package.
Because I have a lot of plots that are getting exported (which are roughly of the same content and seize), I am looking for a good way to let them look the same.
I would like to create a table which explains different cases for electrical phenomena in separate columns. Therefore, I'd like to have a description for each case in the first row, some LaTeX formulas in the second row, some animated diagrams in the third row, further LaTeX formulas, more diagrams etc. The last row should have a single cell, which spans all three columns, and contains an interactive animation where the students can choose from the explained cases and play around with parameters. However, I do not know how to get it all together without leaving the markdown or Python environment.
Alternatively, is there some widget which can contain markdown/LaTeX?
Kind regards,
-Domme
The Issue:
Graphs cant be inserted into cells like images can.
The Request:
The feature "=Image("URL",2)" Should also be available for charts.
You are able to build simple charts within an individual cell using the SPARKLINE function. Here is the documentation.
Here is a simple example:
My specific issue is evident when I output 3 plots to a html report using grid.arrange, sometimes the last plot (which is a tableGrob) is cropped.
I am using 3 separate grid.arrange() statements to place a boxplot, a time series plot and a tableGrob in a html report using knitr.
Code being used to output is:
grid.arrange(p1,top=main)
grid.arrange(p2TS)
if(nrow(over5)>0){
tg=tableGrob(over5,theme=tt3,rows = NULL)
tg$widths = unit(rep(1/4, ncol(tg)), "npc")
grid.arrange(tg)
}
This displays perfectly when the tg object has less than roughly 10 rows of data.
However in testing larger datasets I found that the grid.arrange(tg) outputs in a fixed height "window" in the report which is not desirable.
My question is how can I change the height of the grid.arrange(tg) ouput to match the height of the tg object contained inside (with some top and bottom margin)??
I would appreciate understanding the mechanism by which these properties are changed so I can fine tune my output. I would have a 3x1 grid display all 3 outputs in one line of code if possible but all plots get condensed and unreadable so that is why I have 3 separate grid.arrange() statements. I Guess my real issue is I don't understand how there properties are manipulated here.
Help is greatly appreciated.
I found a workaround to use kable which prints a HTML table to the report instead of grid.arrange() with tableGrob() :
grid.arrange(p1,top=main)
grid.arrange(p2TS)
if(nrow(tg)>0){
print(knitr::kable(tg))
}
Also as I was running this code within a for loop I needed to use a workaround on this issue page which requires me to wrap the kable in a print() statement.
I am trying to create a plot in R using ggplot2. The figure looks great when displayed in R, but when I write it to pdf the labels in the legend slightly overlap the different color lines they are defining. How do I add white space between entries so that this does not happen?
Without code example it is hard to say, but if you don't see this problem in the R display and you see it in the pdf, you can try to increase the pdf output size. When rendering a pdf, the font size is kept and the elements of the graph are more squeezed if the output size is smaller than the displayed one.
p<-ggplot(mpg,aes(cyl,year))+geom_point()
ggsave('yourfile.pdf',p,width=10,height=10) # default is 7 on my install
I don't know if it is possible to change the spacing, but I don't see any parameters for that in the theme() or element_text() documentation