1

I'm currently writing my first shiny app and I'm also pretty new to R. I'm trying to create an App with shinydashboard where users can choose certain values via numericInput which will modify the data frames used for the diagrammes.

I'm using the input in a vector called sc. I use this vector to multiply all numeric columns of a data frame called df_score. From that data frame I later derive other data frames using various computations for diagrams.

This is my code (simplified):

    server <- function(input, output) {

    sc <- reactive({c(input$test1, input$test2, input$test3
          })

  (...some code...)

    observe({
    index <- which(sapply(df_score, is.numeric)== T)
    df_score_mat <- as.matrix(df_score[, index])
    df_score[,index] <- t(t(df_score_mat)*sc())
    })

This is the error message I get:

Warning in t(df_score_mat) * sc() : longer object length is not a multiple of shorter object length

I checked it, the value is the same length as the data frame (also, it worked before I tried to make it reactive content). Did I do sth wrong with the reactive expressions or is there something special about vectors containing reactive values?

I've asked a similar question before, but I just couldn't figure it out. The shiny dashboard does start now but the values are just completely wrong. The diagrams look completely different than before. The input can, and will be, 0 for some of the numeric inputs - it seems something is completely off with those computations... Any help is appreciated!

Chris_589
  • 47
  • 7
  • You need to provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can run the code. You're sure the number of rows of df_score times the number of numeric columns is evenly divisible by 3? That seems like a string assertion that R doesn't think is true. – MrFlick Oct 23 '17 at 15:01
  • Sorry I'll try to produce one tomorrow and add it to my question. Yes I'm sure it's the same, since it worked before I put the `reactive()` around it. – Chris_589 Oct 23 '17 at 15:06
  • I'm not able to produce a reproducible example, and I cannot upload the original code and data unfortunately. Is there any trick on how to check for errors in Shiny Apps? When I wrote the original code, I always checked by printing out my data frame in excel-files. I couldn't figure out how i could do this here since `server`is an expression.. – Chris_589 Oct 24 '17 at 08:19
  • Okay guys, just forget I asked, everything is working fine - I had a typo in the vector... now the app works fine. thanks anyway for this great community – Chris_589 Oct 24 '17 at 08:39

0 Answers0