0

I have been trying to create a table that looks publishable, but I have not been successful.

I have many tables that have very similar coding. The code looks like this...

Data %>% 
  group_by(category) %>% 
  summarise(totalM = length(wordsA),
            Ncue = length(unique(Cue)),
            overall = totalM/Ncue)

Then, when I export my results with rmarkdown I get in the pdf document something like this...

 category           totalM    Ncue      overall
  <chr>             <dbl>    <int>       <dbl>
1 Apositve           27.8      100       0.234
2 Anegative          14.5       40       0.236
3 Bpositive          26.2      100       0.223
4 Bnegative          12.2       50       0.246
5 Cpositive          28.7      100       0.248
6 Cnegative          11.6       50       0.223
7 Dpositive          29.3      100       0.231
8 Dnegative          14.1       50       0.230

So, it looks just like this. I want to add some code to make it look better.

I have been trying with some code that I saw on this platform, but I have not been successful with it.

I don't know if it can be done within R. If not I can always copy-paste it into a Word document and then edit it in Word

Any help would be great. Thanks.

Ajrhjnd
  • 330
  • 1
  • 9

1 Answers1

1

If you want your data look better in Rmarkdown, check kableExtra package. Try this example:

library(kableExtra)
data <- data.frame(Letters=LETTERS[1:10],Numbers=1:10)
data %>%
  kbl() %>%
  kable_paper("hover", full_width = F)

Output: enter image description here

There is others styles.

Marcos Pérez
  • 1,260
  • 2
  • 7