Plotly problem when using tabs in ShinyApps

213 views
Skip to first unread message

Graham

unread,
Jan 15, 2016, 1:28:20 AM1/15/16
to Shiny - Web Framework for R
Hi All 

I am new to this so forgive me for my terminology.

I have started writing shiny apps and everything was working reasonably untill I tried a working shiny app with plotly. Plotly is great for formatting graphs.

So I wrote an app in R and shiny , it worked no problem..then I looked at an example with ggplot on the Plotly website , and repeated it on my pc..fine

Then I took the same code constructs and instead of using the normall ggplot command and the render plot in shint I changed it to the plotly commands ie

1) I changed the ui commands from plotOutput to plotlyOutput and using library(plotly)..as per the example BUT: these commands are inside a tabpanel in my file 
2) in the server I traslated the normal print(p) from ggplot to  gg=p;p1=ggplotly(gg);print(p1) ... and used library(plotly) and the renderPlotly command
3) I left all the text panels and outputs identical.

Result :

When I ran the app , a browser opened with the app.  I have 3 tabs , one is conditional ( a graphics plot) , and the second is a text output tab, the 3rd is a graphics plot 

Nothing wrong with the text tab
Both graphics tabs worked I on pressing them the correct control part or side panels came up , BUT there was no graph !!! What I could do is set the controls on the control panel , go back to the Rstudio Viewer area and intiate the external viewer push button (the one with the straight arrow in the top right ) , and it opened another tab in the browser and there was my plot...which reacted to all the plotly controls.

Therefore has anyone got a working file in shiny with plotly (using ggplot) BUT WITH TABS. (ui plus server ) ?

A second problem is when using the normal ggplot2 inside the example but using geom_smooth with method = "lm" and formula =poly(x,input$order) , or using the stat_smooth constaruct the same error and warning occurs repeatedly  ie

Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Warning: Computation failed in `stat_smooth()`:
object 'weight' not found
Error in order(df$order) : argument 1 is not a vector

This does not happen in shiny without plotly ???

The main question is , if I use tabs in shiny , I cant get a normal output to the browser with the plotly editing  facilityies. 

If anyone is prepared to help I will gladly post my code...But perhaps there is a straight answer. If this should work please post me a working example with 

(shiny , ggplot2, plotly and tabbed output in shiny ) 

Many Thanks 
Graham 


MySchizo Buddy

unread,
Jan 15, 2016, 11:36:20 AM1/15/16
to Shiny - Web Framework for R
please provide a minimal working code

Graham

unread,
Jan 16, 2016, 12:01:44 PM1/16/16
to Shiny - Web Framework for R
Hi

Thx for the response

I uploaded my files , just remove the brackets after the filename ..I am using the diamonds data set with a small mod for 1 column..(Year) ..but the scatterplot part is the part not working so you can use the normal dia,mond data set..

I send u the csv of the full data set anyway.

If you can find an example using a plot, using ggplot2 and plotly,  in atabbed version of shiny app that will be great!

The version without plotly works fine 

Many Thanks

Regards
Gtraham Bortz
server.R(Dash_ggplot_Plotly_V1)
UI.R(Dash_ggplot_Plotly_V1)
diamonds_mod.csv

Graham

unread,
Jan 16, 2016, 12:02:01 PM1/16/16
to Shiny - Web Framework for R
server.R(Dash_ggplot_Plotly_V1)
UI.R(Dash_ggplot_Plotly_V1)
diamonds_mod.zip

Graham

unread,
Jan 16, 2016, 12:02:07 PM1/16/16
to Shiny - Web Framework for R
server.R(Dash_ggplot_Plotly_V1)
UI.R(Dash_ggplot_Plotly_V1)
diamonds_mod.csv
Reply all
Reply to author
Forward
0 new messages