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!