ragged: Display a 'data.frame' with "ragged" keys

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/ragged.R

Description

This is a display method for data.frames to show ragged key/grouping variables, similar to ftable

Usage

1
2
3
4
ragged(indt, keys, blank = "")

## S3 method for class 'ragged'
print(x, ...)

Arguments

indt

The input data.frame or data.table

keys

The variables to be used as keys or grouping variables

blank

The character to print to show nesting. Defaults to "".

x

The object to be printed.

...

Not used.

Value

A list with a "ragged" object and the sorted data.table. The custom print method displays the "ragged" result, but allows further use of data.table.

Author(s)

Ananda Mahto

References

https://stackoverflow.com/q/41324110/1270695

See Also

stats::ftable()

Examples

1
2
3
4
5
6
7
8
9
before= data.frame(C1= c(rep("A", 5), rep("L", 2)),
C2= c("B", rep("E", 3), rep("K", 2), "L"),
C3= c("C", "F", rep("H", 5)),
C4= c("D", "G", "I", rep("J", 4)), 
stringsAsFactors = FALSE)

ragged(before, c("C1", "C2"))
ragged(before, names(before), ":")
ragged(head(ggplot2::diamonds, 30), c("cut", "color"), ":")[, mean(price), .(cut, color)]

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.