Application to extract selected company stocks

Hi all,

I have written a code to extract the stocks information of the companies selected from the input. The codes looks to be fine I believe but I am not getting the output in the application instead I get the output in the R console. (Meaning the application gets closed the moment I execute). Please guide

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    theme: cosmo
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readxl)
library(rhandsontable)
```

```{r}

```

PROMO RECAP
=================

Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
    selectInput("C","Companies",choices = c("","ASHOKLEY.NS","GODREJIND.NS","BOSCHLTD.NS","ADINATH.BO","AREXMIS.BO"))
    actionButton("A","Execute",icon = NULL)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Plots

```{r}
observeEvent(input$A,{
  if(!is.null(input$C)) {
    asd1 <- as.character(input$C[,1])
    as2 <- tq_get(asd1, from = Sys.Date()-10, to = Sys.Date())
    as2 <- as.data.frame(as2)
    output$table1 <- renderRHandsontable({
    rhandsontable(as2)
    })
  }
   else {
    output$table1 <- renderRHandsontable({
    })
  }
})
rHandsontableOutput("table1")
```

Column {data-height=700}
-----------------------------------------------------------------------

### Assumptions, Insights and Recommendations

```{r}

```

I see two problems:

  1. You use the function tq_get() but do not load the package tidyquant
  2. The value input$C is a character vector because it is returned by selectInput(). You should be able to use
asd1 <- input$C

I would expect input$C[,1] to cause an error because it has too many dimensions.

1 Like

Perfect and thanks a lot. It is working

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.