搜索
查看: 1895|回复: 0

10-用shiny创造交互控件

[复制链接]

633

主题

1182

帖子

4030

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4030
发表于 2017-3-16 11:39:15 | 显示全部楼层 |阅读模式
网页里面的各个控件本身也是可以变化的,在shiny里面非常方便的实现:
[AppleScript] 纯文本查看 复制代码
values <- reactiveValues(A=1)
fun <- reactive({ as.character(values$A) })
isolate(fun())
observeEvent(input$do, {
    session$sendCustomMessage(type = 'testmessage',
      message = 'Thank you for clicking')
  })
    df <- eventReactive(input$button, {
      head(cars, input$x)
    })


其中:
eventReactive是为了根据控件的操作来得到变量,返回值必须是一个变量
observeEvent只是根据控件的操作来做一些事情,不需要返回东西。
eventReactive() creates a reactive expression that monitors a reactive value, which is set in the first argument of eventReactive(). The expression will be invalidated whenever the value changes, but it will ignore changes in other reactive values.

reactiveValues() creates a reactive values object, a list of reactive values that you can update and call programmatically. These values are like the values stored in Shiny’s input object with one difference: you can update the values of a reactive values object, but you cannot normally update the values of the input object (those values are reserved for the user to update interactively).
你这个问题很复杂,需要打赏,请点击 http://www.bio-info-trainee.com/donate 进行打赏,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|生信技能树 ( 粤ICP备15016384号  

GMT+8, 2019-12-16 11:34 , Processed in 0.019746 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.