dashR
v0.9.3
文档|画廊
https://dash.plotly.com/r/installation
?确保您至少使用R的
3.0.2版。您可以通过在R CLI中输入version看到哪个版本的R。 Cran是下载最新R版本的最简单的地方。
截至2020-06-04, DASH和当前发布的所有核心组件库的版本都可以通过Cran下载!安装dash及其依赖性很简单
install.packages( " dash " )希望安装包装的(稳定)开发版本以及GitHub的DASH组件的用户可以使用install_github并指定开发分支:
install.packages(c( " fiery " , " routr " , " reqres " , " htmltools " , " base64enc " , " plotly " , " mime " , " crayon " , " devtools " ))
# installs dash, which includes dashHtmlComponents, dashCoreComponents, and dashTable
# and will update the component libraries when a new package is released
devtools :: install_github( " plotly/dashR " , ref = " dev " , upgrade = TRUE )然后,将包装加载到R中:
library( dash )就是这样!
https://dash.plotly.com/r/layout
R软件包破折号使得创建由R驱动的反应性Web应用程序,它提供了一个名为Dash的R6类,该类别可以通过new()方法初始化。
library( dash )
app <- Dash $ new()类似于Python的Dash和Julia的Dash,R应用程序的每个DASH都需要布局(即,用户界面)和回调功能的集合,这些功能定义了更新逻辑时要在输入值更改时执行的更新逻辑。以格式化字符串的基本示例为例:
library( dash )
dash_app() % > %
set_layout(
dccInput( id = " text " , " sample " ),
div( " CAPS: " , span( id = " out1 " )),
div( " small: " , span( id = " out2 " ))
) % > %
add_callback(
list (
output( " out1 " , " children " ),
output( " out2 " , " children " )
),
input( " text " , " value " ),
function ( text ) {
list (
toupper( text ),
tolower( text )
)
}
) % > %
run_app()在这里, showcase = TRUE参数打开一个浏览器窗口,并自动为您加载仪表板应用。
dccGraph library( dash )
# Create a Dash app
app <- dash_app()
# Set the layout of the app
app % > % set_layout(
h1( ' Hello Dash ' ),
div( " Dash: A web application framework for your data. " ),
dccGraph(
figure = list (
data = list (
list (
x = list ( 1 , 2 , 3 ),
y = list ( 4 , 1 , 2 ),
type = ' bar ' ,
name = ' SF '
),
list (
x = list ( 1 , 2 , 3 ),
y = list ( 2 , 4 , 5 ),
type = ' bar ' ,
name = ' Montr U {00E9}al '
)
),
layout = list ( title = ' Dash Data Visualization ' )
)
)
)
# Run the app
app % > % run_app()