forked from plotly/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make R examples within help runnable for CRAN (plotly#734)
* remove \dontrun and use interactive() * ✏️ add single quotes for CRAN
- Loading branch information
Showing
1 changed file
with
68 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,88 @@ | ||
pkg_help_description: >- | ||
An interactive table component designed for editing and exploring | ||
large datasets, DataTable is rendered with standard, semantic HTML | ||
large datasets, 'dashDataTable' is rendered with standard, semantic HTML | ||
<table/> markup, which makes it accessible, responsive, and easy | ||
to style. This component was written from scratch in React.js | ||
specifically for the Dash community. Its API was designed to be | ||
ergonomic and its behaviour is completely customizable through its | ||
to style. This component was written from scratch in 'React.js' | ||
specifically for the 'Dash' community. Its API was designed to be | ||
ergonomic and its behaviour is completely customizable through its | ||
properties. | ||
pkg_help_title: >- | ||
Core Interactive Table Component for Dash | ||
Core Interactive Table Component for 'Dash' | ||
pkg_authors: >- | ||
c(person("Chris", "Parmer", email = "chris@plotly.com", role = c("aut")), person("Ryan Patrick", "Kyle", email = "ryan@plotly.com", role = c("cre"), comment = c(ORCID = "0000-0002-4958-2844")), person(family = "Plotly Technologies, Inc.", role = "cph")) | ||
pkg_copyright: >- | ||
Plotly Technologies, Inc. | ||
r_examples: | ||
- name: dashDataTable | ||
dontrun: TRUE | ||
- name: dashDataTable | ||
dontrun: FALSE | ||
code: | | ||
# For comprehensive documentation of this package's features, | ||
# please consult https://dashr.plot.ly/datatable | ||
# | ||
# A package vignette is currently in development and will | ||
# provide many of the same examples currently available online | ||
# in an offline-friendly format. | ||
library(dash) | ||
library(dashTable) | ||
app <- Dash$new() | ||
# The following if statement is not required to run this | ||
# example locally, but was added at the request of CRAN | ||
# maintainers. | ||
if (interactive()) { | ||
library(dash) | ||
library(dashTable) | ||
# We can easily restrict the number of rows to display at | ||
# once by using style_table: | ||
app$layout( | ||
dashDataTable( | ||
id = "table", | ||
columns = lapply(colnames(iris), | ||
function(colName){ | ||
list( | ||
id = colName, | ||
name = colName | ||
) | ||
}), | ||
style_table = list( | ||
maxHeight = "250px", | ||
overflowY = "scroll" | ||
), | ||
data = df_to_list(iris) | ||
) | ||
) | ||
app <- Dash$new() | ||
app$run_server() | ||
# We can easily restrict the number of rows to display at | ||
# once by using style_table: | ||
app$layout( | ||
dashDataTable( | ||
id = "table", | ||
columns = lapply(colnames(iris), | ||
function(colName){ | ||
list( | ||
id = colName, | ||
name = colName | ||
) | ||
}), | ||
style_table = list( | ||
maxHeight = "250px", | ||
overflowY = "scroll" | ||
), | ||
data = df_to_list(iris) | ||
) | ||
) | ||
app <- Dash$new() | ||
app$run_server() | ||
app <- Dash$new() | ||
# We can also make rows and columns selectable/deletable | ||
# by setting a few additional attributes: | ||
app$layout( | ||
dashDataTable( | ||
id = "table", | ||
columns = lapply(colnames(iris), | ||
function(colName){ | ||
list( | ||
id = colName, | ||
name = colName, | ||
deletable = TRUE | ||
) | ||
}), | ||
style_table = list( | ||
maxHeight = "250px", | ||
overflowY = "scroll" | ||
), | ||
data = df_to_list(iris), | ||
editable = TRUE, | ||
filter_action = "native", | ||
sort_action = "native", | ||
sort_mode = "multi", | ||
column_selectable = "single", | ||
row_selectable = "multi", | ||
row_deletable = TRUE | ||
# We can also make rows and columns selectable/deletable | ||
# by setting a few additional attributes: | ||
app$layout( | ||
dashDataTable( | ||
id = "table", | ||
columns = lapply(colnames(iris), | ||
function(colName){ | ||
list( | ||
id = colName, | ||
name = colName, | ||
deletable = TRUE | ||
) | ||
}), | ||
style_table = list( | ||
maxHeight = "250px", | ||
overflowY = "scroll" | ||
), | ||
data = df_to_list(iris), | ||
editable = TRUE, | ||
filter_action = "native", | ||
sort_action = "native", | ||
sort_mode = "multi", | ||
column_selectable = "single", | ||
row_selectable = "multi", | ||
row_deletable = TRUE | ||
) | ||
) | ||
) | ||
app$run_server() | ||
app$run_server() | ||
} |