[问题] shiny-用户端输入资料汇出dataframe

楼主: naturalsmen (日日夜夜)   2016-04-01 03:22:36
[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]:
各位安安~
小弟最近在用shiny写一个线上分析的示范程式
过程中需要让使用者能够自行输入(或用选单选择)数字及文字
举例来说:
学号 身高 体重 性别 喜欢的电影 ...
我理想中的形式有点像下面三种的结合
1. handsontable
example: https://github.com/jrowen/rhandsontable 或是
shiny::runGitHub("jrowen/rhandsontable",
subdir = "inst/examples/rhandsontable_portfolio")
如handsontable范例中factor的呈现方式最好─像是selectizeInput选单
缺点:使用者无法新增或减少列数
2. shinyTable
https://github.com/trestletech/shinyTable
example: http://pastie.org/10781067 或是
runApp(system.file("examples/01-simple", package="shinyTable"))
我想要的互动形式跟这个package比较像
他能够回传dataframe或matrix
但是不希望像他用输入表格的方式(如范例上方表格)
而是用shiny的widgets像是checkboxInput, selectizeInput赋值
再用actionButton返回
缺点同上
3. shinyIncubator
example: http://pastie.org/10781069
像这里的matrixInput范例就能够用+/-号来新增减少列数
但是!!! 他没办法用character 也不能回传dataframe...orz
总而言之 我想呈现的东西在这里都能找到一部份
但我想了很~~久还是不知道怎么整合...
希望有大大可以帮忙 感恩~
如果我研究出来了会再来更新的
*补充: 因为是用widgets来pass value
只有一列的时候数值会跟着input变动
但若我新增一列后 第一列的值应该要固定 变成第二列的值跟着input变动
*10:30更新
已解决
参考范例:http://pastie.org/10781381
[环境叙述]:
R version 3.2.1 (2015-06-18)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 LC_CTYPE=Chinese (Traditional)_Taiwan.950
[3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 LC_NUMERIC=C
[5] LC_TIME=Chinese (Traditional)_Taiwan.950
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyTable_0.1.0 quantmod_0.4-5 TTR_0.23-0 xts_0.9-7
[5] zoo_1.7-12 reshape2_1.4.1 data.table_1.9.6 metricsgraphics_0.9.0
[9] rhandsontable_0.3.0.2 shiny_0.13.2.9003 devtools_1.10.0.9000
loaded via a namespace (and not attached):
[1] Rcpp_0.12.3 magrittr_1.5 quantstrat_0.8.2 xtable_1.8-2 lattice_0.20-31
[6] R6_2.1.2 stringr_1.0.0 plyr_1.8.3 httr_1.1.0 tools_3.2.1
[11] grid_3.2.1 withr_1.0.1 htmltools_0.3.5 yaml_2.1.13 digest_0.6.9
[16] blotter_0.9.1644 htmlwidgets_0.6 rsconnect_0.4.1.4 memoise_1.0.0 mime_0.4
[21] stringi_1.0-1 jsonlite_0.9.19 httpuv_1.3.3 chron_2.3-47
[关键字]:
shiny, dataframe, interactive
作者: cywhale (cywhale)   2016-04-01 09:46:00
就像matrixInput一样,自己写个wellPanel,附上字段用textInput或者tags$input(id... 再把字段中资料rbind回来重新renderTable(ps actionButton应该可以用icon 如果要设计+的话..如原code也大概如此https://goo.gl/MtwLQK
楼主: naturalsmen (日日夜夜)   2016-04-01 10:29:00
感谢c大 刚刚用了一个很直觉的方式写出来了...http://pastie.org/10781381刚刚在看作者source code时突然想到XDD

Links booklink

Contact Us: admin [ a t ] ucptt.com