I am printing tables - in PDFs - by using data.table()
. In these tables, I want some texts with superscript. I've tried a couples of things, but I only find solutions which are using kable()
or tibble()
- but I really want to use data.table()
or solutions which are using expression()
- which I cannot get working in PDFs.
Here is some simple example code.
library(data.table)
some_table <- data.table(
element = c('Some text with <1> in superscript at the end',
'Some more text')
)
Thank you in advance!
You can use sup
for superscript and sub
for subscript. Maybe you want something like this:
library(DT)
some_table <- datatable(
data.frame(c(1, 2),
row.names = c("Some text with A<sup>1</sup>", "Some more text")), rownames = T, escape = FALSE)
some_table
Output:
It seems like that superscripts expressions are not supported with the data.table
package. You get the following error when trying:
Error in `[.data.table`(x, i, , ) : Internal error: column type 'expression' not supported by data.table subset. All known types are supported so please report as bug.
When using this code:
library(data.table)
my_string <- "'title'^2"
my_title <- parse(text=my_string)
some_table <- data.table(
element = c('Some text with', my_title, 'in superscript at the end',
'Some more text')
)
some_table
```
It seems currently not available for `data.table`.