Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Generated by roxygen2: do not edit by hand

S3method(rpivotTable,data.frame)
S3method(rpivotTable,ftable)
S3method(rpivotTable,table)
export(change_locale)
export(renderRpivotTable)
export(rpivotTable)
Expand Down
44 changes: 38 additions & 6 deletions R/rpivotTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,45 @@
#'
#' @import htmlwidgets
#'
#' @rdname rpivotTable
#' @export

rpivotTable <- function(
data,
rows = NULL,
cols = NULL,
aggregatorName = NULL,
vals = NULL,
rendererName = NULL,
sorter = NULL,
exclusions = NULL,
inclusions = NULL,
locale = "en",
subtotals = FALSE,
...,
width = 800,
height = 600,
elementId = NULL
) {
UseMethod("rpivotTable", data)
}

#' @export
rpivotTable.data.frame <- function(data, ...) {
.rpivotTable(data = data, ...)
}

#' @export
rpivotTable.table <- function(data, ...) {
.rpivotTable(data = data, ...)
}

#' @export
rpivotTable.ftable <- function(data, ...) {
.rpivotTable(data = data, ...)
}


.rpivotTable <- function(
data,
rows = NULL,
cols = NULL,
Expand All @@ -109,13 +145,9 @@ rpivotTable <- function(
height = 600,
elementId = NULL
) {
# check for data.frame, data.table, or array
if( length(intersect(class(data),c("data.frame", "data.table", "table","structable", "ftable" ))) == 0 ) {
stop( "data should be a data.frame, data.table, or table", call.=F)
}

#convert table to data.frame
if( length(intersect(c("table","structable", "ftable"), class(data))) > 0 ) data <- as.data.frame( data )
if( length(intersect(c("table","ftable"), class(data))) > 0 ) data <- as.data.frame( data )

params <- list(
rows = rows,
Expand Down