Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Issues with rows/columns in dataframe for R/Shiny dashboard

$
0
0

I'm trying to create a shiny dashboard that will ask users a series of questions that they answer by sliders (to give numerical answers).I'm then trying to sum the answers of specific questions to make categories which will then output the sum of each category as a radar plot.The user Input section of the code works great, I'm struggling with the dataframe in the server section.

I initially tried this but got an error ("Warning: Error in polygon: invalid value specified for graphical parameter "lwd"") which indicated that there was an issue with recognising columns/rows in the dataframe:

server <- function(input, output) {  # Render radar plot  output$radar_plot <- renderPlot({   # creating vectors using c() functionx1 <- sum(input$q1, input$q2, input$q3, input$q4, input$q5)        x2 <- sum(input$q6, input$q7, input$q8, input$q9, input$q10, input$q11, input$q12, input$q13, input$q14)          x3 <- sum(input$q15, input$q16, input$q17, input$q18, input$q19)  x4 <- sum(input$q20, input$q21, input$q22, input$q23, input$q24)x5 <- sum(input$q25, input$q26, input$q27, input$q28, input$q29, input$q30, input$q31)# creating a DataFrame with above# generated vectorsdata <- data.frame(x1, x2, x3, x4, x5)       # implementing the rbind functionrbind(data)   colnames(data) <- c("x1", "x2", "x3", "x4", "x5")   radarchart(data, axistype = 1, title = "Radar Plot of Cumulative Scores",              pcol = c("skyblue", "red", "green", "yellow", "maroon"), plwd = 1, plty = 1, cglty = 1, cglwd = 1)  })}# Run the applicationshinyApp(ui = ui, server = server)

I then tried this which generated a radar plot but of the value for each question, because I had not specified to summate the data:

server <- function(input, output) {  # Render radar plot  output$radar_plot <- renderPlot({   data <- data.frame(     rbind(       c(0, 0, 0), # Minimum values       c(10, 10, 10), # Maximum values       c(         input$q1, input$q2, input$q3, input$q4, input$q5,         input$q6, input$q7, input$q8, input$q9, input$q10, input$q11, input$q12, input$q13, input$q14,         input$q15, input$q16, input$q17, input$q18, input$q19,         input$q20, input$q21, input$q22, input$q23, input$q24,         input$q25, input$q26, input$q27, input$q28, input$q29, input$q30, input$q31       ) # User inputs     )   )   radarchart(data, axistype = 1, title = "Radar Plot of Cumulative Scores",              pcol = c("skyblue", "red", "green", "yellow", "maroon"), plwd = 1, plty = 1, cglty = 1, cglwd = 1)  })}

How do I summate the data into categories in a way that creates a dataframe that the shiny dashboard can process? Thank you!


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>