0

I'm using the pivottabler package and have finally gotten the table i was looking for. However, I can't do more calculations/table manipulations because the table is in an html widget, not a dataframe. Using as.data.frame() doesn't work- is there anyway to coerce this into a dataframe?

EDIT: the error code displays:

"Error in as.data.frame.default(pivoted) : cannot coerce class ‘c("pivottabler", "htmlwidget")’ to a data.frame"

Shane
  • 1

1 Answers1

0

The pivottabler package provides various conversion functions, including to a data frame:

Please See:
http://pivottabler.org.uk/articles/v05-outputs.html#results-as-an-r-data-frame-1

Example:

library(pivottabler)
pt <- PivotTable$new()
pt$addData(bhmtrains)
pt$addColumnDataGroups("PowerType")
pt$addRowDataGroups("TOC")
pt$defineCalculation(calculationName="TotalTrains", summariseExpression="n()")
pt$evaluatePivot()
df <- pt$asDataFrame()
df

Data frames don't supported merged row/column headers, so it may not make sense to convert.

cbailiss
  • 1,304
  • 11
  • 21