I am working on an app in Shiny for which I import a dataset from a csv to use for visualizations. It works for me to make a plot with ggplot because I specify the dataset, and I can print the dataset from inside the app (so I know it's uploading correctly).
I run into a problem when I want to do some data manipulation that involves the user input (outcome) before I put it into ggplot. Specifically, my dataset is called ace_data and a relelvant variable in that data set is ace_score, and my input variables are the names of the other variables in the ace_data data set. outcome is the label for the user input.
freq <- reactive({
freqs <- c()
for (i in 0:4) {
{freqs <- c(freqs,((sum(ace_data[ace_data$ace_score== i,]$input$outcome))/(sum(ace_data$ace_score == i))))
}}
return(freqs)
})
When I run the app and print freq() I get a vector with all 0s which is incorrect. I have tried attach(ace_data) and ace_data$(input$outcome) but neither of those worked. Thank you!