summary

John Mount

2018-09-18

replyr_summary example.

replyr_summary works on various data sources, counts NA, and returns a data.frame (instead of text).


d <- data.frame(x=c(NA,'b'), y=c(1,NA), stringsAsFactors= FALSE)

summary(d)
 #        x                   y    
 #   Length:2           Min.   :1  
 #   Class :character   1st Qu.:1  
 #   Mode  :character   Median :1  
 #                      Mean   :1  
 #                      3rd Qu.:1  
 #                      Max.   :1  
 #                      NA's   :1

replyr::replyr_summary(d)
 #    column index     class nrows nna nunique min max mean sd lexmin lexmax
 #  1      x     1 character     2   1      NA  NA  NA   NA NA      b      b
 #  2      y     2   numeric     2   1      NA   1   1    1 NA   <NA>   <NA>

execute_vignette <- requireNamespace("RSQLite", quietly = TRUE)
if(execute_vignette) {
  my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
  RSQLite::initExtension(my_db)
  dbData <- dplyr::copy_to(my_db, d)
  
  summary(dbData)
  
  replyr::replyr_summary(dbData)
  
  # glimpse works more like str or head
  dplyr::glimpse(dbData)
}
 #  Observations: ??
 #  Variables: 2
 #  $ x <chr> NA, "b"
 #  $ y <dbl> 1, NA
DBI::dbDisconnect(my_db)
rm(list=ls())
gc()
 #            used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
 #  Ncells 1072123 57.3    1729858 92.4         NA  1729858 92.4
 #  Vcells 2095940 16.0    8388608 64.0      16384  3149606 24.1