Skip to contents

param_table() creates an table inheriting from class “param_table”, generalizing the class “data.frame” and having a more informative print() method for list columns. It is designed for internal usage in the modeltuner package.

The parameter table of a (multi)model (element param) is a “param_table”, and the output of cv_performance() and performance(), too.

Usage

param_table(x, nms = rownames(x))

Arguments

x

A data.frame.

nms

Row names to be attributed to the output table.

Value

A parameter table.

Details

The class “param_table” has a print-method that is often more informative that print.data.frame(). It has some similarities with tibble regarding the rendering of list columns, but it differs in that list elements of length 1 are displayed in a more informative way (see examples).

The class “param_table” has additional methods of cbind(), rbind() and as.data.frame().

Examples

# Create a data.frame with a list as its single column
tbl <- data.frame(row.names = 1:4)
tbl$mixed_list <- list(pi, "anything", y~x, 1:10)

# print as data.frame:
tbl
#>                      mixed_list
#> 1                      3.141593
#> 2                      anything
#> 3                         y ~ x
#> 4 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

if (require(tibble)){
  # print as tibble:
  tibble(tbl)
}
#> Loading required package: tibble
#> # A tibble: 4 × 1
#>   mixed_list
#>   <list>    
#> 1 <dbl [1]> 
#> 2 <chr [1]> 
#> 3 <formula> 
#> 4 <int [10]>
   
# print as param_table:
param_table(tbl)
#>   mixed_list
#> 1  3.1416   
#> 2  anything 
#> 3  y ~ x    
#> 4  <int>[10]