I am having trouble with the drop-down menu options and their outputs. Although I can see the list of options the output remains the same and doesn't change even though the user can pick a different person. Any suggestions are welcome! My code is below (I removed some sensitive information):
server.r
senators <- read.csv("senators.csv")
output$senator <- renderUI({
selectInput("variablex",
#inputID = "senator",
label = "Choose a U.S Senator from the list",
selected = senators$name,
choices = senators$name)
})
senTweets <- read.csv("person.year.count.csv")
person <- reactive({
req(variablex)
df <- senTweets %>%
group_by(input$variablex, year) %>%
top_n(input$a, n) %>%
ungroup() %>%
arrange(word, -n)
return(df)
})
observe({
df = input$df
})
output$plot <- renderPlot({
person () %>% mutate(word = reorder(word, n))
ggplot(aes(word, n, fill = factor(year))) +
geom_col(show.legend = FALSE) +
facet_wrap(~ year, scales = "free") + scale_fill_viridis_d() +
coord_flip() + labs(y="Word frequency", x="Term", title = paste("Top words used in 2020"))
})
}
ur.r
ui <- dashboardPage(
dashboardHeader(title = ""),
dashboardSidebar(sidebarMenu(
menuItem("Main", tabName = "Main", icon = icon("r-project")),
menuItem("ReadMe", tabName = "ReadMe", icon = icon("readme"))
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "Main",
sidebarPanel(
helpText("text"),
uiOutput('senator'),
sliderInput(
"a",
label = "Select value to view top common words",
min = 1,
max = 10,
value = 5
),
),
mainPanel(
plotOutput("plot")
)
),
tabItem(tabName = "ReadMe",
includeMarkdown("README.md"))
),
)
)
UPDATE: I made the following changes as gss suggested but I still can't get the output to change, any tips? Also not sure if the observe made a difference but I added that line as well.
Let's try some debugging. I don't have data which you have, so I don't see other possibilities. After reading your code there are two parts which I'm not sure if there are correct. Here is the first part:
person <- reactive({
#req(variablex)
df <- senTweets %>%
group_by(input$variablex, year) %>%
top_n(input$a, n) %>%
ungroup() %>%
arrange(word, -n)
})
First of all, input$variablex is a name (senator's name), right? (Or should be at least). So I assume that senTweets data contains columns with the names which are present in senators$name. Otherwist it won't be possible to group by. input$variablex, as all inputs from shiny, is of type character, so the first thing is that you should probably use some knowledge about programming with dplyr (Programming with dplyr) and use .data[[input$variablex]]:
person <- reactive({
#req(variablex)
df <- senTweets %>%
group_by(.data[[input$variablex]], year) %>%
top_n(input$a, n) %>%
ungroup() %>%
arrange(word, -n)
})
This should not be a problem with input$a because it is just a number and even if top_n() function expects number, probably there are a implicit type conversion.
You can change the code according my adive or first you can check if you really get what you want when user chooses senator's name. To do this, add browser() function here:
person <- reactive({
#req(variablex)
df <- senTweets %>%
group_by(input$variablex, year) %>%
top_n(input$a, n) %>%
ungroup() %>%
arrange(word, -n)
browser()
})
(you may need to add req(input$variablex) at the beginning, otherwise it can be that you do not choose any senator and after opening the app, you will immediately will be moved to the console in RStudio)
When you open the app, choose senator, then go back to RStudio and you should be in debugging mode. Type df in the console and check if this table looks as you think it should.
The second part of your code which seems suspicious is this one:
output$plot <- renderPlot({
person () %>% mutate(word = reorder(word, n))
ggplot(data = person(), aes(word, n, fill = factor(year))) +
geom_col(show.legend = FALSE) +
facet_wrap(~ year, scales = "free") + scale_fill_viridis_d() +
coord_flip() + labs(y="Word frequency", x="Term", title = paste("Top words used in 2020"))
})
Especially this: person () %>% mutate(word = reorder(word, n)) (it changes person() data, but do not save those changes!) doesn't seem to do anything useful. More sense would be to have:
output$plot <- renderPlot({
person () %>% mutate(word = reorder(word, n)) %>%
ggplot(aes(word, n, fill = factor(year))) +
geom_col(show.legend = FALSE) +
facet_wrap(~ year, scales = "free") + scale_fill_viridis_d() +
coord_flip() + labs(y="Word frequency", x="Term", title = paste("Top words used in 2020"))
})
Related
I have a shiny app that lets the user add categories to the facet_wrap. When I start with one category the plot fills the entire box but when I add a second category, the initial plot adjusts to half the initial size. Is there any way I can set the size, such that the first facet fits half the box and doesn't adjust in size when I add a second category?
Here's what I happens when I choose a second facet category:
Current behavior
Here's what I want to happen:
desired behavior
Here is a simple reprex--when you add a second feature from select feature, it adjusts the size of the first plot.
I found a decent solution and added it to this example using the ggh4x::facet_manual. However, this solution does not work with ggplotly and in a bs4dash box, it starts to look crammed in my app where there are upwards of 40 plots. Ideally, I'd like the box to be scrollable. Thanks in advance for any suggestions!
library(shiny)
library(tidyverse)
library(glue)
library(ggh4x)
library(plotly)
library(janitor)
library(bs4Dash)
iris_df <- iris %>%
clean_names() %>%
mutate(extra_feature1 = sepal_length,
extra_feature2 = sepal_width,
extra_feature3 = petal_length,
extra_feature4 = petal_width,
extra_feature5 = sepal_length,
extra_feature6 = sepal_width,
extra_feature7 = petal_length,
extra_feature8 = petal_width) %>%
select(species, everything()) %>%
pivot_longer(-species) %>%
mutate(feature = glue("{name}_{species}"))
iris_species <- iris_df %>%
clean_names() %>%
distinct(species) %>%
pull()
iris_features <- iris_df %>%
clean_names() %>%
distinct(feature) %>%
pull()
# Define UI for application that draws a histogram
ui <- dashboardPage(dark = FALSE,
# Application title
dashboardHeader("Reprex"),
# Sidebar with a slider input for number of bins
dashboardSidebar(skin = "light",
selectInput("species",
"Select species:",
choices = iris_species,
selectize = FALSE,
multiple = TRUE,
selected = iris_species[1]
),
selectInput("features",
"Select feature:",
choices = iris_features,
selectize = TRUE,
multiple = TRUE,
selected = iris_features[1]
),
radioButtons("facets", label = "View all features:",
choices = list("On" = "facet_wrap", "Off" = ""),
selected = "", inline = FALSE)),
# Show a plot of the generated distribution
dashboardBody(
fluidRow(box(
plotOutput("densityPlot"),
width=12,
headerBorder = FALSE,
collapsible = FALSE))
))
# Define server logic required to draw a histogram
server <- function(input, output, session) {
observeEvent(input$species,
{updateSelectInput(session,
"features",
choices = unique(iris_df$feature[iris_df$species == input$species]),
selected = iris_df$feature[1])
})
design <- matrix(c(1:12), 2, 6, byrow = FALSE)
output$densityPlot <- renderPlot({
if (input$facets == '') {
p1 <- iris_df %>%
filter(species %in% input$species) %>%
filter(feature %in% input$features) %>%
ggplot(aes(value, fill = species)) +
geom_density(alpha = .5) +
theme_light() +
facet_manual(~name, scales = "free", design = t(design), respect = FALSE)
#facet_wrap(~name, scales = "free")
p1
}
else {
iris_df %>%
filter(species %in% input$species) %>%
ggplot(aes(value, fill = species)) +
geom_density(alpha = .5) +
theme_light() +
facet_wrap(~name, ncol = 2, scales = "free")
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
I am calculating correlation for each country between Number of Daily Covid Cases & Daily Vaccination.
There are two df, one for Confirmed Cases & other for Vaccinations:
library(tidyverse)
library(lubridate)
library(glue)
library(scales)
library(tidytext)
library(shiny)
library(shinydashboard)
file_url1 <- "https://raw.githubusercontent.com/johnsnow09/covid19-df_stack-code/main/ts_all_long4.csv"
file_url2 <- "https://raw.githubusercontent.com/johnsnow09/covid19-df_stack-code/main/vaccination_data.csv"
ts_all_long <- read.csv(url(file_url1))
vaccination_data <- read.csv(url(file_url2))
ts_all_long <- ts_all_long %>%
mutate(date = as.Date(date))
vaccination_data <- vaccination_data %>%
mutate(date = as.Date(date))
When I use above data to run correlation in rmarkdown then it works:
ts_all_long %>%
left_join(y = vaccination_data,
by = c("Country.Region" = "location", "date", "continent", "iso3c" = "iso_code")) %>%
na.omit() %>%
group_by(Country.Region) %>%
summarise(COR = cor(Confirmed_daily, total_vaccinations),
total_vaccinations_per_hundred = first(total_vaccinations_per_hundred)) %>%
arrange(COR) %>%
na.omit() %>%
slice(c(1:15, ( n()-14): n() ))
Issue: When I use this inside shiny with SelectInput at total_vaccinations to make dynamic Parameter then it gives this error:
Problem with summarise() input COR. [31mx[39m incompatible
dimensions [34mi[39m Input COR is cor(Confirmed_daily, as.numeric(input$id_vaccination_type)). [34mi[39m The error
occurred in group 2: Country.Region = "Argentina".
ui
fluidRow(
style = "border: 1px solid gray;",
h3("Vaccination to Cases Correlation Analysis"),
column(4, style = "border: 1px solid gray;",
selectInput(inputId = "id_vaccination_type", label = "Choose Vaccination Parameter",
choices = c("total_vaccinations","people_vaccinated","people_fully_vaccinated"),
selected = "total_vaccinations")
),
column(8, style = "border: 1px solid gray;",
plotOutput("top_corr_countries", height = "550px") #
)
Server
corr_data <- reactive({
corr_data <- ts_all_long %>%
left_join(y = vaccination_data,
by = c("Country.Region" = "location", "date", "continent", "iso3c" = "iso_code")) %>%
na.omit() %>%
group_by(Country.Region) %>%
summarise(COR = cor(Confirmed_daily, as.numeric(input$id_vaccination_type)) ,
total_vaccinations_per_hundred = first(total_vaccinations_per_hundred)) %>%
na.omit() %>%
arrange(COR) %>%
na.omit() %>%
slice(c(1:15, ( n()-14): n() ))
})
output$top_corr_countries <- renderPlot({
corr_data() %>%
ggplot(aes(x = COR ,
y = fct_reorder(Country.Region, -COR),
col = COR > 0)) +
geom_point(aes(size = total_vaccinations_per_hundred)) +
geom_errorbarh(height = 0, size = 1, aes(xmin = COR, xmax = 0)) +
geom_vline(xintercept = 0, col = "midnightblue", lty = 2, size = 1) +
theme(
panel.grid.major = element_blank(),
legend.position = "NULL") +
labs(title = glue("Top Countries by +/- Correlation with Vaccination as of {max(vaccination_data$date)}"),
subtitle = "Size is proportional to Vaccination per Population",
y = "", x = "Correlation",
caption = "Data source: covid19.analytics
Created by: ViSa")
})
NOTE: I have also published this problem in another link but it sounds more complex in there so I have tried to rephrase it in this one to make it simpler.
Other post: Unable to renderPlot on adding a selectInput option for variable in shiny which runs perfectly fine otherwise
input$id_vaccination_type is a character string of the variable you want to select.
To actually select thevalues of that variable you can turn the name of the variable into a symbol and evaluate it, for example with the bang-bang operator !!.
So one solution would be:
cor(Confirmed_daily, as.numeric(!! sym(input$id_vaccination_type))
I'm not sure if this will make your app work (I can't download the csv files on github and would prefer dput for a minimal example), but it should solve this specific problem.
There are other solutions to this problem. One is to use get instead of !! sym(input)). The other is to use varSelectInput, which returns actual names and not strings (so here the problem should not arise in the first place).
Problem:
I was trying to build a shiny app that plot frequency of n-grams based on a user specified column from a user uploaded csv. In addition, a function was added to plot the senetiment over time, based on a date column specified by the user as well.
The app was working okay locally, with Warning, but failed work after published. Please see the following for a reproducible example.
Preparation: libraries and example data
# Load R packages
library(shiny)
library(tidyverse)
library(shinythemes)
library(lubridate)
library(tidytext)
library(textdata)
# Creating a example csv file for upload
Sample_csv <-
data.frame(text = janeaustenr::emma,
id = 1:length(janeaustenr::emma),
date = sample(seq(as.Date('1900/01/01'), as.Date('1920/01/01'), by="day"),
replace = T,
length(janeaustenr::emma)))
write.csv(Sample_csv, "Sample_csv.csv", row.names = F)
UI
ui <- fluidPage(theme = shinytheme("united"),
titlePanel("Text glancer"),
sidebarLayout(
sidebarPanel(
# Input: Select a file ----
fileInput("csv_file", "Feed csv here",
multiple = FALSE,
accept = c(".csv")),
#Conditional panel
conditionalPanel(
# use a server side condition
condition = "output$fileUploaded",
# Input: Select ----
uiOutput("text_select"),
# Input: Select ----
uiOutput("date_select"),
# Input: Simple integer interval ----
sliderInput("top_frequency", "Top n ngrams to be plotted:",
min = 5, max = 20, value = 10),
# Input: Select ----
selectInput("ngrams", "Ngrams of your choice:",
c("Single word" = 1,
"Bigram" = 2,
"Trigram" = 3)
)
),
# Submit bottom
submitButton("Update View", icon("refresh"))
),
# sidebarPanel
mainPanel(
tabsetPanel(
tabPanel(h2("Most frequenlty used n-grams"),
plotOutput("frequency_plot", height = 900, width = 1200)),
tabPanel(h2("Sentiment of the months"),
plotOutput("sentiment_plot", height = 900, width = 1200))
)
)
)
)
server
server <- function(input, output, session) {
# create reactive version of the dataset (a data.frame object)
LOAD_DATA <- reactive({
infile <- input$csv_file
if (is.null(infile))
{return(NULL)}
{read_csv(infile$datapath)}
})
# inform conditionalPanel wheter dropdowns sohould be hidden
output$fileUploaded <- reactive({
return(!is.null(LOAD_DATA()))
})
outputOptions(output, 'fileUploaded', suspendWhenHidden=FALSE)
## update 'column' selectors
output$text_select <- renderUI({
if(is.null(LOAD_DATA()))
{return(NULL)}
else
selectInput("text_col", "Select the text column:", colnames(LOAD_DATA()))
})
output$date_select <- renderUI({
if(is.null(LOAD_DATA()))
{return(NULL)}
else
selectInput("date_col", "Select the date column (ymd):", colnames(LOAD_DATA()))
})
# Create reactive parameters
TOP_FREQUENCY <- reactive({
input$top_frequency
})
N_GRAMS <- reactive({
as.numeric(as.character(input$ngrams))
})
# Output frequency of ngrams
output$frequency_plot <- renderPlot( {
if(is.null(LOAD_DATA()))
{return(NULL)}
else{
WORK_DATA <- LOAD_DATA()[,c(input$text_col,
input$date_col)]
names(WORK_DATA) <- c("TEXTS", "DATES")
CSV_DOC_N_Grams <-
WORK_DATA %>%
# LOAD_DATA() %>%
# select(TEXTS = TEXT_COL(), DATES = DATE_COL()) %>%
mutate(TEXTS = gsub("http.*", " ", TEXTS)) %>%
# mutate(text = gsub("\\#.* |\\#.* .|\\#.* ,", " ", text)) %>%
unnest_tokens(words, TEXTS, token = "ngrams", n = N_GRAMS()) %>%
select(words) %>%
filter(str_detect(words, "[a-zA-Z]")) %>%
separate(words, c("word1","word2","word3"),sep = " ", remove = F) %>%
filter(! word1 %in% stop_words$word &
! word2 %in% stop_words$word&
! word3 %in% stop_words$word)
#Counting ngrams
CSV_DOC_N_Gramss_Count <-
CSV_DOC_N_Grams %>%
count(words, sort=T) %>%
select(N_Gram_Text = words,
N_Gram_Count = n)
#Plotting ngram frequency
CSV_DOC_N_Gramss_Count_freq <-
CSV_DOC_N_Gramss_Count %>%
mutate(N_Gram_Text = fct_reorder(N_Gram_Text, N_Gram_Count)) %>%
top_n(TOP_FREQUENCY(), N_Gram_Count) %>%
ggplot(aes(x = N_Gram_Text,
y = N_Gram_Count,
fill = N_Gram_Count)) +
geom_col()+
coord_flip() +
scale_fill_gradient2()+
labs(title = paste0("Top ", TOP_FREQUENCY(), " ngrams used in csv doc"),
x = "ngrams",
y = "frequency") +
theme_bw()+
theme(legend.position = "none",
axis.text.x = element_text(face='bold',size=12),
axis.text.y = element_text(face='bold',size=12),
axis.title.x = element_text(face='bold',size=18),
axis.title.y = element_blank())
print(CSV_DOC_N_Gramss_Count_freq)
}
})
output$sentiment_plot <- renderPlot( {
if(is.null(LOAD_DATA())){return(NULL)}
else{
WORK_DATA <- LOAD_DATA()[,c(input$text_col,
input$date_col)]
names(WORK_DATA) <- c("TEXTS", "DATES")
tk_afinn <-
WORK_DATA %>%
mutate(TEXTS = gsub("http.*", " ", TEXTS)) %>%
unnest_tokens(word, TEXTS) %>%
filter(! word %in% stop_words$word) %>%
filter(str_detect(word, "[a-zA-Z]")) %>%
filter(! DATES %in% NA) %>%
inner_join(get_sentiments("afinn")) %>%
mutate(YEAR_Month = ymd(paste(year(DATES),
month(DATES),
"1", sep="-"))) %>%
group_by(index = YEAR_Month) %>%
summarise(sentiment = sum(value))
tk_afinn_plot <-
tk_afinn %>%
ggplot(aes(x = index, y = sentiment)) +
geom_line()+
labs(x = "date (year-month)",
y = "sentiment of the month") +
theme_bw()+
theme(legend.position = "none",
axis.text.x = element_text(face='bold',size=12),
axis.text.y = element_text(face='bold',size=12),
axis.title.x = element_text(face='bold',size=18),
axis.title.y = element_blank())
print(tk_afinn_plot)
}
})
}
Fuse
shinyApp(ui = ui, server = server)
Warnings:
After loading the csv file, the local app reports :
"Problem with mutate() input TEXTS.
object 'TEXTS' not found
Input TEXTS is gsub("http.*", " ", TEXTS)."
After specify the text column and date column, both tab showed plots. However, after publishing it to shinyapp.io, it reports error and would not run.
Can anybody help with this issue? I have consulted the other thread includin this>https://stackoverflow.com/questions/47248534/dynamically-list-choices-for-selectinput-from-a-user-selected-column, but still no luck.
Any insight would be greatly appreciated!
I am providing here an executable simple R shiny application to plot two lines based on column names.
library(shiny)
library(reshape2)
library(ggplot2)
library(dplyr)
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
uiOutput("moreControls")
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Cross dating", plotOutput("plot1"))
)
)
)
))
server <- shinyServer(function(input, output) {
datasetInput <- data.frame(chrono_A = rnorm(16,0),chrono_B = rnorm(16,0))
row.names(datasetInput) <- c(seq(2000, 2015))
col_names <- colnames(datasetInput)
output$moreControls <- renderUI({
checkboxGroupInput("variable", "Filter Options", col_names)
})
# Plot data
output$plot1 <- renderPlot({
datasetInput_short <- mutate(datasetInput, year = as.numeric(row.names(datasetInput)))
datasetInput_short <- melt(datasetInput_short, id = c("year"))
datasetInput_short <- dplyr::filter(datasetInput_short, variable %in% input$variable)
ggplot(datasetInput_short, aes(x = year, y = value, group = variable, col = variable)) +
geom_line() + theme_bw() + ylim(-3, 3)
})
})
shinyApp(ui = ui, server = server)
I would like to add two features, which would allow me to move the plotted lines in two ways:
By adding a window where I can directly add the final year for the curve (ideally, the current final year would be entered automatically)
By adding two additional buttons (+ and -), and by clicking them I move each line by one year
Please, see the image below:
Any suggestion is highly appreciated.
I reread your description, maybe this might be helpful, though not entirely sure this is what you have in mind.
You can add two textInput widgets and then add filters to your data so that the data displayed for A and B have years less than these values.
In addition, you can have reactiveValues that include an offsets for A and B that increase/decrease when the buttons are pressed. These offsets will change the year column from the filtered data for A and/or B.
server <- shinyServer(function(input, output) {
datasetInput <- data.frame(chrono_A = rnorm(16,0),chrono_B = rnorm(16,0))
row.names(datasetInput) <- c(seq(2000, 2015))
col_names <- colnames(datasetInput)
rv <- reactiveValues(offset_A = 0, offset_B = 0)
observeEvent(input$but_plus_A, {
rv$offset_A <- rv$offset_A + 1
})
observeEvent(input$but_minus_A, {
rv$offset_A <- rv$offset_A - 1
})
observeEvent(input$but_plus_B, {
rv$offset_B <- rv$offset_B + 1
})
observeEvent(input$but_minus_B, {
rv$offset_B <- rv$offset_B - 1
})
datasetInput_short <- reactive({
datasetInput %>%
mutate(year = as.numeric(row.names(.))) %>%
pivot_longer(cols = starts_with("chrono_"), names_to = "variable", values_to = "value") %>%
dplyr::filter(variable %in% input$variable,
(variable == "chrono_A" & year < input$sel_A) | (variable == "chrono_B" & year < input$sel_B)) %>%
mutate(year = if_else(variable == "chrono_A", year + rv$offset_A, year),
year = if_else(variable == "chrono_B", year + rv$offset_B, year))
})
output$moreControls <- renderUI({
list(
checkboxGroupInput("variable", "Filter Options", col_names),
textInput("sel_A", "Year A", 2015),
actionButton("but_plus_A", "", icon = icon("plus")),
actionButton("but_minus_A", "", icon = icon("minus")),
textInput("sel_B", "Year B", 2015),
actionButton("but_plus_B", "", icon = icon("plus")),
actionButton("but_minus_B", "", icon = icon("minus"))
)
})
# Plot data
output$plot1 <- renderPlot({
ggplot(datasetInput_short(), aes(x = year, y = value, group = variable, col = variable)) +
geom_line() + theme_bw() + ylim(-3, 3)
})
})
Edit:
Based on OP comment below, say you do not know the column names, but there are always 2 columns to work with, you can do the following. You can use the column names vector col_names when filtering.
datasetInput_short <- reactive({
datasetInput %>%
mutate(year = as.numeric(row.names(.))) %>%
pivot_longer(cols = all_of(col_names), names_to = "variable", values_to = "value") %>%
dplyr::filter(variable %in% input$variable,
(variable == col_names[1] & year < input$sel_A) | (variable == col_names[2] & year < input$sel_B)) %>%
mutate(year = if_else(variable == col_names[1], year + rv$offset_A, year),
year = if_else(variable == col_names[2], year + rv$offset_B, year))
})
It is possible to dynamically generate more than 2 sets of inputs (for example, using 3: A, B, and C) but that would be a bit more complex.
I have the following code on my Server. R
data_agg_plot1<- reactive({
brush1 <- linked_brush(keys = data_agg()$id, "navy" )
data_agg <- data_agg()
plot1<-data_agg%>%
ggvis(x = ~dates_all) %>%
group_by(factor(dates_all.1)) %>%
layer_points(y = ~ value, fill =~dates_all.1, shape =~dates_all.1) %>%
layer_paths(y = ~ value, stroke = ~dates_all.1 , strokeOpacity := 0.5) %>%
scale_ordinal("fill", range = c("green", "red", "blue"))%>%
scale_ordinal("shape", range = c("triangle-up","triangle-down","circle")) %>%
scale_ordinal("stroke",range=c("green","red","blue")) %>%
brush1$input() %>%
hide_legend(c('stroke','fill'))%>%
add_legend(c('shape','fill'),
title = "Symbol", orient = "left",
values = c("New hires", "Attrition" , "Net Growth"),
properties = legend_props(
title = list(fontSize = 16))) %>%
add_axis("x",properties= axis_props(labels = list(angle=60,align = "left")),
tick_padding =0,
title = "") %>%
add_axis("y", title = "Total Count") %>%
set_options(width = "auto",height = 400) %>%
scale_numeric('y',clamp = TRUE)
return(list(plot1,brush1))
})
so this is a reactive function that returns me a list of 2 functions, a plot and my brush object.
the purpose of doing so is so that I can make my keys reactive - this is so that I can make an additional plot based on my user's selection. think of it as the second plot depends on what the first user highlights in the first plot.
this is my following code:
plot1_data<-reactive({
data_agg_plot1()[[1]]
})
plot1_data%>%bind_shiny("plot1")
selected_plot1 <- reactive({
data_agg_plot1()[[2]]
})
output$test <- renderPrint({
temp <- selected_plot1()$selected()
print(temp)
})
however, when I print out the selection, it is all false,
please refer to the image below:
can anybody explain to me how to overcome this?
I highly suspect I have to re-write my linkedbrush function,
I have tried both solutions from:
linked_brush in ggvis cannot work in Shiny when data change
but it does not work.