Skip to contents

Print a nicely formatted version of a diffdf object.

Usage

# S3 method for class 'diffdf'
print(x, row_limit = 10, as_string = FALSE, file = NULL, ...)

Arguments

x

A comparison object created by diffdf().

row_limit

Maximum number of rows to display in difference tables. Use NULL to show all rows. Default is 10.

as_string

Logical. If TRUE, returns the printed message as an R character vector instead of printing to the console. Default is FALSE.

file

A connection or a character string naming the file to print to. If NULL (the default), output is printed to the console.

...

Additional arguments (not used).

Examples

x <- subset(iris, -Species)
#> Warning: ‘-’ not meaningful for factors
x[1, 2] <- 5
COMPARE <- diffdf(iris, x)
#> Warning: 
#> There are rows in BASE that are not in COMPARE !!
#> Not all Values Compared Equal
print(COMPARE)
#> Differences found between the objects!
#> 
#> Summary of BASE and COMPARE
#>   ====================================
#>     PROPERTY      BASE        COMP    
#>   ------------------------------------
#>       Name        iris         x      
#>      Class     data.frame  data.frame 
#>     Rows(#)       150          1      
#>    Columns(#)      5           5      
#>   ------------------------------------
#> 
#> 
#> There are rows in BASE that are not in COMPARE !!
#> First 10 of 149 rows are shown in table below
#>   ===============
#>    ..ROWNUMBER.. 
#>   ---------------
#>          2       
#>          3       
#>          4       
#>          5       
#>          6       
#>          7       
#>          8       
#>          9       
#>         10       
#>         11       
#>   ---------------
#> 
#> 
#> Not all Values Compared Equal
#>   =================================
#>      Variable    No of Differences 
#>   ---------------------------------
#>    Sepal.Length          1         
#>    Sepal.Width           1         
#>    Petal.Length          1         
#>    Petal.Width           1         
#>      Species             1         
#>   ---------------------------------
#> 
#> 
#>   ============================================
#>      VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   --------------------------------------------
#>    Sepal.Length        1        5.1     NA    
#>   --------------------------------------------
#> 
#> 
#>   ===========================================
#>     VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   -------------------------------------------
#>    Sepal.Width        1        3.5      5    
#>   -------------------------------------------
#> 
#> 
#>   ============================================
#>      VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   --------------------------------------------
#>    Petal.Length        1        1.4     NA    
#>   --------------------------------------------
#> 
#> 
#>   ===========================================
#>     VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   -------------------------------------------
#>    Petal.Width        1        0.2     NA    
#>   -------------------------------------------
#> 
#> 
#>   ==========================================
#>    VARIABLE  ..ROWNUMBER..   BASE   COMPARE 
#>   ------------------------------------------
#>    Species         1        setosa   <NA>   
#>   ------------------------------------------
#> 
#> 
print(COMPARE, row_limit = 5)
#> Differences found between the objects!
#> 
#> Summary of BASE and COMPARE
#>   ====================================
#>     PROPERTY      BASE        COMP    
#>   ------------------------------------
#>       Name        iris         x      
#>      Class     data.frame  data.frame 
#>     Rows(#)       150          1      
#>    Columns(#)      5           5      
#>   ------------------------------------
#> 
#> 
#> There are rows in BASE that are not in COMPARE !!
#> First 5 of 149 rows are shown in table below
#>   ===============
#>    ..ROWNUMBER.. 
#>   ---------------
#>          2       
#>          3       
#>          4       
#>          5       
#>          6       
#>   ---------------
#> 
#> 
#> Not all Values Compared Equal
#>   =================================
#>      Variable    No of Differences 
#>   ---------------------------------
#>    Sepal.Length          1         
#>    Sepal.Width           1         
#>    Petal.Length          1         
#>    Petal.Width           1         
#>      Species             1         
#>   ---------------------------------
#> 
#> 
#>   ============================================
#>      VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   --------------------------------------------
#>    Sepal.Length        1        5.1     NA    
#>   --------------------------------------------
#> 
#> 
#>   ===========================================
#>     VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   -------------------------------------------
#>    Sepal.Width        1        3.5      5    
#>   -------------------------------------------
#> 
#> 
#>   ============================================
#>      VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   --------------------------------------------
#>    Petal.Length        1        1.4     NA    
#>   --------------------------------------------
#> 
#> 
#>   ===========================================
#>     VARIABLE    ..ROWNUMBER..  BASE  COMPARE 
#>   -------------------------------------------
#>    Petal.Width        1        0.2     NA    
#>   -------------------------------------------
#> 
#> 
#>   ==========================================
#>    VARIABLE  ..ROWNUMBER..   BASE   COMPARE 
#>   ------------------------------------------
#>    Species         1        setosa   <NA>   
#>   ------------------------------------------
#> 
#> 
print(COMPARE, file = "output.txt")