Make part of a cell italic using grid.table - css

I am making a table and I would like to make parts of some cells italic. For example with the following code:
grid.table(iris[1:5, 1:3])
I get this table:
I would like to make the characters "Length" italic. I need the solution to be applicable to any cells in the table, not just the header.

Related

Editing ppt table cell text using R (officer)

Is there a way (maybe using some combination of the ph functions) to edit the text of a table in-place, or delete the table and replace it with an exact copy containing updated data? The table needs very distinct and specific dimension formatting, and has arrow shapes contained in some of the cells.
I used ph_label to idebtify the label for thr table, but I wasn't able to come up with a more granular way of labeling the text of specific cells within the table.

How to edit legend labels in google spreadsheet plots?

I'm trying to plot some data in Google spreadsheet:
And as you may see all of the series are in a same column and I can't use the any of the rows as headers. My plot looks like this:
I would appreciate if you could help me know how I can edit/add legend labels.
Unfortunately I don't think the graphs were intended for your data format.
The only way I've been able to work out how to add a header is by reformatting my data so I have the header at the top of my ranges.
So I suggest you split your data into separate columns so you have;
D2:D4, E2:E4, F2:F4 etc with D1, E1, and F1 as your header and then selecting "Use row 1 as your headers." From the data menu.
Alternatively, you could add labels to the series themselves. Although not ideal, it could be quicker than reformatting your data. On the data menu, click on the three dots of a data series to bring up a menu that allows you to add a label. Unfortunately this needs to be a cell so you'll have to have that header on your sheet some where.
I had the same question this year (2021), and it looks like there's support for it now. In short, you just have to double-click on the empty legend item for the series, and it'll give you a place to put text, directly in the chart.
Here's what my chart looked like (with no series titles):
If you double-click on one, you'll get a small text input area.
Type in your series name and then press enter or click outside of the input area.
Repeat this for each series, and you should be good to go.
I had the same problem because I was selecting only the data I wanted to include in the chart and not the entire table, headers and all. When you create a chart in Google Sheets and you want to use a row or column (or both) as strings that are included in the chart's labeling, you must select the entire table before choosing the Chart command from the Insert menu.
After doing so, you may need to do all or some of the following:
Switch rows/columns if your axes are not correct
Eliminate any rows/columns that you don't want represented by editing the Data Range field in the chart editor
Select Use column A as headers or Use row 1 as headers
You could also potentially use the add labels option when clicking on the 3 dots in the series section:
Double-click on the symbols in your legend, then double-click on the symbol for the series you would like to label; you should be able to directly enter your legend label now. You can do further text formatting using the chart editor on the right.
I took them to a new sheet. first selected only the X-axis and one of the columns that will appear as one. label. In this sheet, I made all the "labels" as a header of the sheet. and added them one by one as a series. and this time it. add them as a label.
obviously this is a workaround and the bug should be fixed :) hopefully.

Plot a table where specific rows can be highlighted (gridExtra alternative)

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.

Adding text to a plot with a specified color for each letter

I'd like to add text to a plot, where each letter in the text has a specified color.
I know addtable2plot of the plotrix package allows adding a table (data.frame or matrix) to a plot, and allows the background colors of each cell to be specified. Unfortunately the same does not seem to apply for the text. So I was wondering if anyone has an idea how to achieve this.
For example:
plot(density(rnorm(1000,4,1)))
would be my plot
and then I would like to add this text:
c("T","T","A")
with these corresponding colors:
c("red","red","blue")

How to specify titles for tableGrobs in grid.arrange (from gridExtra)?

It looks like grid.arrange() ignores the name attribute of tableGrob. Let's say I want to plot tables with titles...
baz<-lapply(seq(3),function(ii)
tableGrob(format(matrix(runif(8),nrow=2,
dimnames=list(LETTERS[1:2],letters[1:4])),digits=3),
name=paste0('n',ii)));
This plots them but without titles: do.call(grid.arrange,c(baz,nrow=1))
It seems like overkill to screw around with creating lists of textGrobs, calculating their height, etc. I just want to force there to be an extra line above the header of each table, displaying the name I gave to that table. Or some built-in argument to do so.

Resources