Hi andresrcs,
I tested this, and the issue I kept having was with the error message pasted below as well as a message that says "disconnected to server Reload" on the actual page.
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
[shinyapps]: 65: stop
[shinyapps]: 64: .getReactiveEnvironment()$currentContext
[shinyapps]: 63: getCurrentContext
[shinyapps]: 62: .subset2(x, "impl")$get
[shinyapps]: 61: $.reactivevalues
[shinyapps]: Error in .getReactiveEnvironment()$currentContext() :
[shinyapps]: 59: server [/srv/connect/apps/shiny_004/app.R#76]
[shinyapps]: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
I believe the issue is that I am not treating the information being read in from the session$clientData$url_search as a reactive value.
Pasted below is some of the server code. I wonder if you might suggest how to load this data table in a way that treats the variable as reactive? I have tried assigning it to reactiveValues(), but that has not worked.
server <- function(input, output, session) {
#read the information from the URL
values <- reactiveValues(id = session$clientData$url_search)
#Establish connection to API
project <- redcapConnection(url,
token)#token will be placed here
#export only records associated with the subject Id passed to records
graph_data <- exportRecords(project,records = c(values$id)) %>%
#select only the fields being assessed
select('smell_cosmetics_intensity',
'smell_spice_intensity',
'smell_fruit_intensity',
'smell_other_intensity',
'nasalirritation_intensity',
'taste_bitter_intensity',
'taste_salt_intensity',
'taste_sour_intensity',
'taste_sweet_intensity')
#transmute the table to generate a column for week and the averaged smell and taste values
data <- transmute(graph_data,
week = 0:(nrow(graph_data)-1),
smell = ((smell_cosmetics_intensity + smell_spice_intensity + smell_fruit_intensity + smell_other_intensity) / 4),
smell_2 = nasalirritation_intensity,
taste = ((taste_bitter_intensity + taste_salt_intensity + taste_sour_intensity + taste_sweet_intensity)/4),
taste_2 = nasalirritation_intensity)
#Generate the oral summary graph
output$oral_graph <- renderPlot({
#this is the R code used to generate the Oral graph
oral_graph <- ggplot(data, aes(x = week)) +
geom_line(aes(y = taste), color = "green") +
geom_line(aes(y = taste_2), color = "blue") +
geom_point(aes(x = week, y = taste)) +
geom_point(aes(x = week, y = taste_2)) +
xlab("Time (weeks)") +
ylab("Response to Stimuli") +
theme_classic() +
theme(text = element_text(size = 16))
#return statement
oral_graph
})