0

I have a list containing 10 tables from 10 correlation tests. I'm trying to pass it as an argument to report_table() from library(report), get it, and use it to plot them all at once with nice_table() from library(rempsyc) in a single report (one report under the other)

  • I've made a reproducible example with two tests:
### empty list:

test_list <- list()

### make two tests to provide an example:

for (a in 1:2) {
  
  myVar <- data[a]    
  myVarn <- names(myVar)
  data$myVarUnlist <- unlist(myVar)
  
  
 test_list[[a]] <- cor.test(data$myVar, data$VarC, data = data)
  
}

### my list: 

test_list

### I can plot one at once, but I'd like to plot both at the same time:

library(report)
library(rempsyc)

reports <- list()

for (b in 1:2) {
  
 my_report <- report_table(test_list[[b]])
  
 reports[[b]]  <- nice_table(my_report)
  
}

### I have two reports, but how can I join them all? 
### I wanted one under the other as a single table

reports
  • desired output:

output

  • data :
structure(list(VarA = c(263L, 223L, NA, 257L, 285L, 211L, 210L, 
NA, 147L, 311L, 342L, 97L, 216L, 241L, 296L, 296L, 211L, 60L, 
339L, 318L, 358L, 167L, NA, 183L, 92L, 283L, 169L, NA, 298L, 
NA, 162L, NA, 211L, 308L, 92L, 269L, NA, 197L, 280L, 259L, 313L, 
252L, 98L, 258L, 201L, 341L, 456L, 308L, 252L, 64L, 259L, 158L, 
161L, NA, NA, 129L, 264L, NA, 216L, 109L, 91L, 236L, 275L, 254L, 
221L, NA, NA, NA, NA, NA, NA), VarB = c(145L, 120L, NA, 119L, 
142L, 132L, 100L, NA, 64L, 144L, 164L, 56L, 102L, 136L, 139L, 
135L, 91L, 32L, 123L, 164L, 145L, 93L, NA, 99L, 51L, 143L, 98L, 
NA, 158L, NA, 79L, NA, 96L, 149L, 55L, 114L, NA, 94L, 137L, 130L, 
135L, 113L, 61L, 113L, 117L, 154L, 199L, 152L, 142L, 42L, 111L, 
74L, 92L, NA, NA, 85L, 116L, NA, 99L, 64L, 60L, 114L, 151L, 136L, 
116L, NA, NA, NA, NA, NA, NA), VarC = c(145L, 121L, NA, 120L, 
145L, 133L, 101L, NA, 64L, 146L, 166L, 58L, 103L, 136L, 142L, 
135L, 91L, 34L, 123L, 167L, 148L, 93L, NA, 99L, 51L, 145L, 98L, 
NA, 159L, NA, 81L, NA, 97L, 149L, 56L, 115L, NA, 96L, 137L, 132L, 
135L, 113L, 62L, 113L, 118L, 154L, 199L, 154L, 145L, 43L, 112L, 
74L, 92L, NA, NA, 86L, 116L, NA, 100L, 66L, 60L, 114L, 153L, 
136L, 120L, NA, NA, NA, NA, NA, NA), myVarUnlist = c(145L, 120L, 
NA, 119L, 142L, 132L, 100L, NA, 64L, 144L, 164L, 56L, 102L, 136L, 
139L, 135L, 91L, 32L, 123L, 164L, 145L, 93L, NA, 99L, 51L, 143L, 
98L, NA, 158L, NA, 79L, NA, 96L, 149L, 55L, 114L, NA, 94L, 137L, 
130L, 135L, 113L, 61L, 113L, 117L, 154L, 199L, 152L, 142L, 42L, 
111L, 74L, 92L, NA, NA, 85L, 116L, NA, 99L, 64L, 60L, 114L, 151L, 
136L, 116L, NA, NA, NA, NA, NA, NA)), row.names = c(NA, -71L), class = "data.frame")
  • Thanks in advance! :)

  • Additional question, I'm using the unlisted variable so that cor.test doesn't return me any errors, is there a way to keep the variable originals' name? (aka, VarA, VarB, etc) ? I've tried with the myVarn , but cor.test() won't run with that
Larissa Cury
  • 806
  • 2
  • 11

0 Answers0