0

I am using R markdown and trying to extract the output of the summary function into a nice table but the actual values that are coming in the output are not extracted into the table.

Library(tidyverse)
Library(kableextra)

ATT <- read_excel('E:/MY PROJECTS/OSTEOTOMY ACL/ATT.xlsx')
Flexion_Degrees Load_Direction  Load_N  Osteotomy_Type  PTS_Degrees Paper   ATT_ACL
30  Anterior    134 Native  0   Nelitz  5.5
90  Anterior    134 Native  0   Nelitz  4
30  Anterior    134 AOWO    5   Nelitz  5.8
90  Anterior    134 AOWO    5   Nelitz  4
summary(ATT)

I got an output like that

Flexion_Degrees Load_Direction         Load_N     
 Min.   :15      Length:30          Min.   : 18.0  
 1st Qu.:30      Class :character   1st Qu.:100.0  
 Median :30      Mode  :character   Median :134.0  
 Mean   :39                         Mean   :179.3  
 3rd Qu.:30                         3rd Qu.:206.8  
 Max.   :90                         Max.   :400.0

Then I used

ATT_STATS_Table <- ATT %>%  
  select(PTS_Degrees,Flexion_Degrees,ATT_ACL,Load_N)  

as.data.frame(apply(ATT_STATS_Table,2,summary)) %>% 
  kbl() %>% 
  kable_styling()

And the output is like that with no values?

PTS_DegreesFlexion_DegreesATT_ACLLoad_NLength30303030ClasscharactercharactercharactercharacterModecharactercharactercharactercharacter
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • 1
    Your code works for me. Could you try it again? – YH Jang Apr 13 '23 at 01:59
  • 1
    This works fine for me using the built-in `mtcars` dataset. If you still have the problem in a fresh R session, we'd need to see your data to diagnose any issues. you can share your data by pasting the result of `dput(ATT_STATS_Table)` (as text, not a screenshot). Also see [How to make a great R reproducible example](https://stackoverflow.com/q/5963269/17303805). – zephryl Apr 13 '23 at 02:03
  • I tried the code again, I get the following error: Error in dimnames(x) <- dnx : 'dimnames' applied to non-array – Ahmed Mabrouk Apr 13 '23 at 17:37
  • my data with dput(ATT_STATS_Table) : structure(list(PTS_Degrees = c(0, 0, 5, 5, 10, 10, 15, 15, 8, 12.1, 16.3, 8, 12.1, 16.3, 9.9, 0, 9.9, 0, 10, 10, 0, 0, 10, 10, 0, 0, -0.9, 1, -0.9, 1), Flexion_Degrees = c(30, 90, 30, 90, 30, 90, 30, 90, 15, 15, 15, 15, 15, 15, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 90, 90), – Ahmed Mabrouk Apr 13 '23 at 17:38
  • ATT_ACL = c(5.5, 4, 5.8, 4, 5.7, 3.8, 5.2, 3.1, 0.6, 2.1, 3.2, NA, 1.4, 6.7, 3.8, 2.354, 6.339, 2.649, 1.7, 3.7, 1, 2.4, 4.6, 4.7, 5.7, 6, 5, 3.03, 1.675, 2.587), Load_N = c(134, 134, 134, 134, 134, 134, 134, 134, 18, 18, 18, 18, 108, 209, 400, 400, 400, 400, 200, 400, 200, 400, NA, NA, NA, NA, 100, 100, 100, 100)), row.names = c(NA, -30L), class = c("tbl_df", "tbl", "data.frame")) – Ahmed Mabrouk Apr 13 '23 at 17:38

0 Answers0