coord_polar in shiny

287 views
Skip to first unread message

A. She.

unread,
May 23, 2017, 11:27:45 AM5/23/17
to Shiny - Web Framework for R
It's non working.

library(shiny)
library
(ggplot2)
library
(plotly)


ui
<- fluidPage(
    plotlyOutput
("plot")
   
)


server
<- function(input, output) {
   
   
output$plot <- renderPlotly({
        pie
<- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
            geom_bar
(width = 1)
        pie
+ coord_polar(theta = "y")
           


       
        ggplotly
()
   
})
   
   
}


shinyApp
(ui, server)
Why?

Joe Cheng

unread,
May 23, 2017, 1:09:44 PM5/23/17
to A. She., Shiny - Web Framework for R
You're not passing anything into ggplotly; you need to pass the ggplot object you've created.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/68e34477-4851-4885-984e-d07dc9dec1b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

A. She.

unread,
May 24, 2017, 3:08:13 AM5/24/17
to Shiny - Web Framework for R, chei...@gmail.com
Hi Joe! I'm your fan )).
But in R it's work!

pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
            geom_bar
(width = 1)
        pie
+ coord_polar(theta = "y")



вторник, 23 мая 2017 г., 19:09:44 UTC+2 пользователь Joe Cheng [RStudio] написал:

Joe Cheng

unread,
May 24, 2017, 3:15:46 AM5/24/17
to A. She., Shiny - Web Framework for R
In case I wasn't clear:

        pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
            geom_bar
(width = 1)

        pie <- pie 
+ coord_polar(theta = "y")
        ggplotly
(pie)

A. She.

unread,
May 29, 2017, 4:17:37 AM5/29/17
to Shiny - Web Framework for R, chei...@gmail.com
A'm sorry, but I have error, and only with coord_polar. It's work without coord_polar, and coord_polar works without shiny.

rm(list = ls())

library
(shiny)
library
(ggplot2)
library
(plotly)


ui
<- fluidPage(
    plotlyOutput
("plot")
)


server
<- function(input, output) {

    data
=data.frame(group=c("A ","B ","C ","D ") , value=c(33,62,56,67) )

    output$plot
<- renderPlotly({
        pie
<- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
            geom_bar
(width = 1)

        pie
<- pie + coord_polar(theta = "y")
        ggplotly
(pie)

   
})
}
shinyApp
(ui, server)


Warning in min(z$x.range) :
  no non-missing arguments to min; returning Inf
Warning in max(z$x.range) :
  no non-missing arguments to max; returning -Inf
Warning in min(z$y.range) :
  no non-missing arguments to min; returning Inf
Warning in max(z$y.range) :
  no non-missing arguments to max; returning -Inf
Warning: Error in zero_range: x must be length 1 or 2
Stack trace (innermost first):
    87: zero_range
    86: scales::rescale
    85: gg2list
    84: ggplotly.ggplot
    83: ggplotly
    82: "plotly"::"ggplotly" [#8]
    81: func
    80: origRenderFunc
    79: output$plot
     4: <Anonymous>
     3: do.call
     2: print.shiny.appobj
     1: <Promise>

среда, 24 мая 2017 г., 9:15:46 UTC+2 пользователь Joe Cheng [RStudio] написал:

Joe Cheng

unread,
May 31, 2017, 3:04:06 AM5/31/17
to A. She., Shiny - Web Framework for R
Does coord_polar work even with ggplotly if you don't use Shiny?

A. She.

unread,
Jun 1, 2017, 3:51:57 AM6/1/17
to Shiny - Web Framework for R, chei...@gmail.com
You're right. It's not work without Shiny to.

pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
    geom_bar
(width = 1)
pie
<- pie + coord_polar(theta = "y")
ggplotly
(pie)

Error in zero_range(to) : x must be length 1 or 2
In addition: Warning messages:
1: In min(z$x.range) : no non-missing arguments to min; returning Inf
2: In max(z$x.range) : no non-missing arguments to max; returning -Inf
3: In min(z$y.range) : no non-missing arguments to min; returning Inf
4: In max(z$y.range) : no non-missing arguments to max; returning -Inf



среда, 31 мая 2017 г., 9:04:06 UTC+2 пользователь Joe Cheng [RStudio] написал:
Reply all
Reply to author
Forward
0 new messages