Hi
I create a variable with a link
urlLink1 <- a("R Community", href="https://forum.posit.co/")
i put this variable urlLink1 inside text string and on click, the site opens, no issue in opening the URL.
But the problem is R Dashboard gets reloaded and gets initialized. Is there any solution to stop R to reload, but to just open the URL on browser
sorry, same problem, opening a blank window. please check from your side. if it works then there must be something wrong in my setup
could you please check and confirm
Thanks Scott, sorry for the delay. here is the example code that demonstrates the issue
library(shiny)
library(ggplot2)
urlinfluencediagnostic <- a("URL Link: Thanks to Bookdown.org for the valuable contribution on Doing Meta-Analysis in R:",
href = "https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/heterogeneity.html?q=%20Influence%20Analysis#influence-analysis"
)
ui <- fluidPage(
column(
width = 10,
offset = 1,
align='center',
tags$br(),
HTML("When you click the button, you will get the plot, but then when you click the url Link, the dashboard gets reloaded, the plot goes off "),
tags$br(),
actionButton(inputId = 'mGetMePlot',label = "Get me the Plot"),
plotOutput(outputId = 'mmtcarsPlot',width = '100%',height = '400px'),
tags$br(),
urlinfluencediagnostic
)
)
server <- function(input, output, session) {
data(mtcars, package="datasets")
observeEvent(input$mGetMePlot,{
output$mmtcarsPlot <- renderPlot({
ggplot(mtcars, aes(x=hp, y=mpg, color=cyl )) +
geom_point(size=3)
})
})
}
shinyApp(ui, server)
Thanks for the code. When I run the code as-is using "Run External", I can generate the plot, and then when I click the link , I am taken to the website. When I hit the back button, I come back to the app and the plot is reset as you describe.
However, adding the statement target = "_blank" to the url (see below), I can generate the plot, and now when I click the link, a new window is launched and the app is left unchanged (plot still shows).
urlinfluencediagnostic <- a("URL Link: Thanks to Bookdown.org for the valuable contribution on Doing Meta-Analysis in R:",
href = "https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/heterogeneity.html?q=%20Influence%20Analysis#influence-analysis",
target = "_blank"
)
I ran the original code using "Run in Window" and "Run in Viewer Pane" and never experienced the app resetting after clicking the link. The only time it did for me was in the scenario I described above (i.e. using the back button to get back to the app in "Run External"). I hope this helps.
Thanks Scott,
sorry I am not getting it right. I get a blank new window, when i click the link, plot is not disturbed.
probably there must of some setting gone wrong in my Rstudio.
Wow, resolved, Thanks Scott
after making "Run External" and by adding target = "_blank" as you suggested, first the shiny app opens in browser and click on the URL link opens up next tab with the web site. your perseverance is very much appreciated