Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R shiny应用程序中的Slideify测验小部件_R_Shiny_Slidify - Fatal编程技术网

R shiny应用程序中的Slideify测验小部件

R shiny应用程序中的Slideify测验小部件,r,shiny,slidify,R,Shiny,Slidify,我想在一个闪亮的应用程序中使用测验小部件,或者让它与闪亮的应用程序一起工作。这个想法是SlidefUI将捕获股票的名称,我希望以某种方式将此选择传递给一组R代码,这些代码将反过来将值传递给测验小部件。但是,我不知道如何在一个闪亮的应用程序之外传递一个值,或者如何让测验小部件在闪亮的应用程序中工作。我想: -从SlidefUI中选择股票 -捕获此选定值 -使用所选股票从名为BetaData的data.frame中提取市场贝塔和行业贝塔,以便我可以提取该股票的行业和市场贝塔 -在测验中使用提取的市场

我想在一个闪亮的应用程序中使用测验小部件,或者让它与闪亮的应用程序一起工作。这个想法是SlidefUI将捕获股票的名称,我希望以某种方式将此选择传递给一组R代码,这些代码将反过来将值传递给测验小部件。但是,我不知道如何在一个闪亮的应用程序之外传递一个值,或者如何让测验小部件在闪亮的应用程序中工作。我想:

-从SlidefUI中选择股票 -捕获此选定值 -使用所选股票从名为BetaData的data.frame中提取市场贝塔和行业贝塔,以便我可以提取该股票的行业和市场贝塔 -在测验中使用提取的市场测试版和行业测试版 -我的测试代码工作正常,我只是不知道如何捕获我在UI中所做的选择并将其传递给使用此信息的R代码

我的代码是

---
title       : R-Squared Risk Management
subtitle    : Products & Services
author      : Arun Soni
job         : Director of Business Development 
logo        : rsqlogo.jpg
widgets     : [bootstrap, quiz, shiny, interactive]
# download: 'io2012.zip'
url         : {lib: ../../libraries}
mode        : selfcontained
hitheme     : tomorrow
assets      : {js: 'test.js'}
--- dt:10

```{r echo = F}
opts_chunk$set(cache = F)
```

## Agenda ##

<style>
body {
  background-color: #000;
}
.quiz-option label{
  display: inline;
  font-size: 1em;
}
ul.nav li::before { content: ""; }  
ul.nav li{ font-size: 18px; line-height: 24px;}
</style>

### 1. About ###
### 2. RSQRM Models ###
### 3. Analytics ###
### 4. Optimisation###
### 5. Backtesting###
### 6. Alpha Research###
### 7. Conclusion###

---&radio

## Exposure vs. Weight - Does it matter?


```{r opts.label = 'shiny'}
slidifyUI(
  sidebarPanel(
    selectInput(inputId='betaInput', label='Choose Stock',  choices=c('APPLE','BASF'),selected='APPLE INC',selectize = TRUE)
  ),
  mainPanel(
    textOutput("sSelected")
  )
)

shinyServer(function(input, output) {

  sSelected <- reactive({
        switch(input$model,dtBetaMelted[['Name']])
    })
  })
```

Market or Industry?

```{r opts.label='marketIndustryBeta',echo=FALSE}

marketBeta <- BetaData[StockName==sSelected,MarketBetaCol]
industryBeta <- BetaData[StockName==sSelected,IndustryBetaCol]
```

1. _`r if(marketBeta>industryBeta){'Market'}else{'Industry'}`_
2. `r if(marketBeta<industryBeta){'Market'}else{'Industry'}`

*** .hint

Industry beta is `r sprintf(industryBeta,fmt='% 3.2f')` & market beta is `r sprintf(marketBeta,fmt='% 3.2f')`

*** .explanation

这不起作用,因为测验部分不在更新的反应上下文中。虽然这是一个有趣的想法,但在当前的设计下,很难将测验小部件合并到一个闪亮的上下文中。我正在探索其他想法,稍后可能会对此有所了解。