make_dull: Hide dull columns in data frames

Description Usage Arguments Details Value Examples

Description

make_dull AKA make.dull adds a "dull" S3 class to designated columns in a data.frame. When the data.frame is printed, entries in those columns will show up just as "...". Useful for hiding long boring stuff like nucleotide sequences, MD5 sums, and filenames. Columns will still print clearly if manually extracted.

The dull class has methods for format (used when printing a data.frame) and [, so that dullness is perpetuated.

Usage

1
make_dull(df, cols)

Arguments

df

a data.frame

cols

columns to designate

Details

Ask yourself: do you really want details of a function called make_dull? Life may be sweet but it is also short.

More details

make_dull is both autologous and idempotent.

Value

A modified data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Becos more logical syntax:
rsample <- function (n = length(pop), pop, replace = FALSE, prob = NULL){
  pop[sample(seq_along(pop) - 1, size = n, replace = replace, prob = prob) + 1]
}
df <- data.frame( x=1:3,
    y=apply( matrix( rsample( 150, as.raw( 33:127), rep=TRUE), 50, 3), 2, rawToChar),
    stringsAsFactors=FALSE) # s.A.F. value shouldn't matter
df # zzzzzzzzzzzzzzz
df <- make_dull( df, 'y')
df # wow, exciting!
df$y # zzzzzzzzzzzzzz

mvbutils documentation built on May 2, 2019, 8:32 a.m.

Related to make_dull in mvbutils...