Designing specific cells according to the indices

How can i design specific cells according to their indices? It's clear to me how i can design specific cells according to their values. i can't use this approach as i have different cells with the same value that i want to have a different design. Specifically, i need to turn three cells at positive and three others at negative angle. And they have the same content. So only indices can differentiate them.

We need a reproducible example (reprex)

It wouldn't make much sense to produce a source code here. Let's imagine that there's a 2 * 2 matrix! Both cells contain the text "jrkrideau" like that:

jrkrideau | jrkrideau
jrkrideau | jrkrideau

i want the content of the first cell to be at the angle of 10 degrees and the content of the third cell to be at the angle of 350 degrees like that:

jrkrideau (at 10°) | jrkrideau (at 0°)
jrkrideau (at 350°) | jrkrideau (at 0°)

Apparently you are trying to format some kind of table. We ave no idea what R package you are using or what the data looks like. Without more information and some sample data I do not see how we can help.

Now i get why you wanted a minimal example - one can make tables using several packages.

i use kable for tables.

Let's say that the data looks like exactly as i posted previously! In order to be more clear:

a <- c("jrkrideau", "jrkrideau")
b <- c("jrkrideau", "jrkrideau")
table <- data.frame(a, b)

That table i send into kable as data. i know how rotate a whole row or a whole column, want to know how to only rotate a cell, for instance the third one. There's a way to use LaTex for that if i turn jrkrideau into $\\begin{turn}{10}jrkrideau\\end{turn}$ however this doesn't look nice in the source code although obvious and am wondering whether there's a way to do that with kable without involving LaTex.

I do not think I have ever seriously used kable but as I understand it Yihui intended it to be really basic so I doubt that it will handle what you want.

When you say, "i know how rotate a whole row or a whole column" are you doing this is with the Kable (knitr::kable() function or using the kableExtra package?

I see that one can rotate a row or column with kableExtra but I don't see how to do a single cell. You may be stuck with the latex code.

I believe that the flextable package may be able to do what you want though it may not be flexible enough.

ft_1 <- flextable(head(iris))
ft_1 <- rotate(ft_1, i = 1:2, j = 1, align = "bottom", rotation = "tbrl", part = "body")

For rotating a whole column or row, i used kableExtra.

flextable doesn't do the rotation as i want: by any angle. It can only rotate by a number of right angles.

I was afraid of that. I cannot think of any other package that will do what you want at the moment but there are a lot of table packages out there.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.