0

I want to save output from my R markdown in a table format that I can directly add in my publication.

The code does wilcoxson signed rank test on multiple variables at the same time. I want to export the output I get from the modellist into a table format such that I can have the p - value and the variable names.

Additionally, I also tried using the sjt.frq() function from the sJplot library to get summary statistics for my likert scale data but apparently sjt.frq() does not show up anymore, does anyone know if it has been removed and why does it not show in R anymore? I have added the code I used with sjt.frq().

Thank you for the hep!


samp<-structure(list(ID_formerge = c(44422.98569, 44423.08525, 44423.09342, 44423.09724, 44423.82518), Participant = c("4", "5", "6", "7", "8"), ID_formerge.1 = c("C4", "C5", "C6", "C7", "C8"), country = c("Colombia-Bucaramanga", 
"Colombia-Bucaramanga", "Colombia-Bucaramanga", "Colombia-Bucaramanga", "Colombia-Bucaramanga"), Fecha_bankssp = c(44422L, 44423L, 44423L, 44423L, 44423L), att1_goodofall = c(4L, 4L, 2L, 4L, 4L), att2_pvtdisease = c(4L, 4L, 3L, 3L, 4L),att3_curedisease = c(4L, 2L, 4L, 3L, 3L), att4_timewaste = c(4L, 4L, 3L, 5L, 4L), att5_helpgenerations = c(4L, 4L, 4L, 4L, 3L), att6_healthinterfere = c(4L, 3L, 3L, 5L, 3L), att7_helpfamily = c(4L, 3L, 3L, 3L, 4L), att8_noriskstolen = c(4L, 2L, 3L, 4L, 2L), att9_helpdengue = c(4L, 4L, 4L, 4L, 2L), att10_perinfosafe = c(4L, 4L, 3L, 4L, 2L), att11_identhealthproblem = c(4L, 2L, 3L, 3L, 4L), att12_highmedicalcost = c(4L, 3L, 2L, 4L, 3L)), row.names = c(NA, 
5L), class = "data.frame")


modellist<-list()
for(i in 6:17){
    fmla <- formula(paste(names(samp)[i], "~ country"))
    modellist[[i]]<-wilcox.test(fmla, data = samp, paired = FALSE)
}

>#I tried the following way but it did not work.
samp%>%tab_cells(sheet(att1_goodofall,att2_pvtdisease,att3_curedisease))%>%tab_cols(total(label = "W"),am)%>%
                  tab_stat_fun_df(
                    
                    funcation(x){
                            
                      modellist<-list()
                        for(i in 6:17){
                                        fmla <- formula(paste(names(samp)[i], "~ country"))
                                        modellist[[i]]<-wilcox.test(fmla, data = sam, paired = FALSE)
                                        sheet('p-value' = coef(modellist), confint(model))
                                        
                                              }
                        
                    }
                    
                  )%>%tab_pivot()


sjt.frq(samp$att1_goodofall,variablelabels=variables['att1_goodofall'],valuelablels=values[['att1_goodofall']])

  • what format does your publication require? – Paul Stafford Allen Dec 16 '22 at 09:34
  • @PaulStaffordAllen In a simple table format. – Mahir Bhatt Dec 16 '22 at 09:51
  • 1
    The question is, how are you going to include that table in your publication. Do you work in latex or word or something different? Do you want to save it as Excel file and then include it or do you want something you can copy-paste directly into the publication file? – benimwolfspelz Dec 16 '22 at 10:36
  • benimwolfspelz is correct, that's what I was asking. "In a simple table format" could be a .csv file, a png image, and excel worksheet, a string of markup text like LaTeX or HTML to include the formatting etc. - if you are publishing to a journal they should provide guidelines. If you are putting it in your own report then only the data matters, you can format it inside the report in word or however you are choosing to do it. – Paul Stafford Allen Dec 16 '22 at 11:01
  • @PaulStaffordAllen I am using Micosoft word. And exporting in a csv format that can give me a table would be best option, I will later format it in word. Thanks. – Mahir Bhatt Dec 16 '22 at 11:58
  • Then simply using `write.csv()` will do the job - check the documentation for that function for more. – Paul Stafford Allen Dec 16 '22 at 13:30
  • @PaulStaffordAllen I tried write.csv() but it did not work. I get the following ```error cannot coerce class ‘"htest"’ to a data.frame``` – Mahir Bhatt Dec 16 '22 at 13:36

0 Answers0