rhandsontable

Introduction

Handsontable is a data grid component with an Excel-like appearance. Built in JavaScript, it integrates with any data source with peak efficiency. It comes with powerful features like data validation, sorting, grouping, data binding, formula support or column ordering. (via)

Types

The table includes support for numeric, logical, character and Date types. Logical values will appear as check boxes, and the pikaday.js library is used to specify Date values.

rhandsontable attempts to map R classes to an appropriate handsontable type. Factors will be mapped to dropdown, with the choices specified by level and allowInvalid set to FALSE. To allow new levels, set allowInvalid to TRUE (using hot_col; it may also be desirable to set strict to FALSE). When running in shiny, using hot_to_r will preserve custom factor ordering, and if new levels are allowed, they will be added to the end.

To improve readability, NA values will be displayed as blank cells. This requires converting columns containing NA to characters, and in the case of factors and Dates, may not display the data in the desired format. It may be beneficial to concert these type of columns to character before passing to rhandsontable.

For shiny apps, use renderer = htmlwidgets::JS("safeHtmlRenderer") to display columns with html data. The allowed html tags default to <em><b><strong><a><big>, but the (hidden) allowedTags parameter can in rhandsontable can be used to customize this list.

Custom Renderer using an R Parameter

Additional parameters passed to rhandsontable will be available to the JavaScript widget via the params property.

Right-Click

Right-clicking in a cell will enable a context menu that includes customizable table actions via the hot_context_menu function. For shiny apps, formatting and comment updates made via the context menu are not currently retained.

To disable the context menu, set contextMenu = FALSE in hot_table (or rhandsontable).

Add / Remove Rows & Columns

By default a user can add or remove table rows and columns, but this functionality can be disabled. Note that Handsontable does not allow column be added or deleted to the table if column types are defined (i.e. useTypes == TRUE in rhandsontable).