0

The following code consists of five functions. When wrapTables is run, only the t table is output? How to fix so each table outputs with a title for each such as "Chi-Square Table" followed by the chi-square table of probabilities? Thanks.

MM

wrapTables <- function() {
chistable()
ftableb()
normtab()
poissontable2()
ttable()
}

wrapTables() 
Mary A. Marion
  • 780
  • 1
  • 8
  • 27
  • 4
    We don't have the code for any of the wrapped functions, but to start with you are not using `return()` or `print()` to explicitly output anything. This means that by default you only output the object on the last line of the function. – Calum You Sep 08 '18 at 21:20
  • Possible duplicate of [Explicitly calling return in a function or not](https://stackoverflow.com/questions/11738823/explicitly-calling-return-in-a-function-or-not) – divibisan Sep 10 '18 at 18:22

1 Answers1

2

Consider returning a named list containing each function's output:

wrapTables <- function() { 
   list(Chi_Square_Table = chistable(),
        F_Table = ftable(),
        Norm_Table = normtab(),
        Poisson_Table = poissontable2(),
        T_table = ttable()
   )
}

Then any assigned object to this function will have elements named accordingly:

output <- wrapTables()

output$Chi_SquareTable
output$F_Table
output$Norm_Table
...

Or all together but in list format:

output
Parfait
  • 104,375
  • 17
  • 94
  • 125