boxuancui / DataExplorer

Automate Data Exploration and Treatment
http://boxuancui.github.io/DataExplorer/
Other
512 stars 88 forks source link

plot_str not rendering with R Shiny #97

Closed aagarw30 closed 5 years ago

aagarw30 commented 5 years ago

Hello, I am trying to plot the structure of my dataset using the plot_str(). The function works well when I use in R console however when integrated with R Shiny it does not show up the plot.

Here is the reproducible example. Not sure if I am making a mistake or rendering incorrectly.

library(shiny)
library(DataExplorer)

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

server <- function(input, output, session) {
  output$plot <- renderPlot({
    print(plot_str(iris))
  })
}

shinyApp(ui, server)

Additionally, I am running this in WIN OS, str_intro() renders perfectly in R Shiny.

sessionInfo() R version 3.4.4 (2018-03-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale: [1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252
[3] LC_MONETARY=English_India.1252 LC_NUMERIC=C
[5] LC_TIME=English_India.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] randomForest_4.6-14 DiagrammeR_1.0.0 rpart.plot_3.0.6
[4] rpart_4.1-13 DataExplorer_0.7.0 DT_0.4
[7] shinyjs_1.0 shinyBS_0.61 shinydashboard_0.7.0 [10] shiny_1.0.5 caret_6.0-81 ggplot2_3.0.0
[13] lattice_0.20-35

Thanks in advance for help.

aagarw30 commented 5 years ago

Forgot to mention that I have tried rendering with and without print() but no success.

output$plot <- renderPlot({
  print(plot_str(iris))
})

output$plot <- renderPlot({
  plot_str(iris)
})
boxuancui commented 5 years ago

Have you tried diagonalNetworkOutput in ui and renderDiagonalNetwork in server? These plots are sourced from networkD3 package.

aagarw30 commented 5 years ago

Hello, No, let me try them and confirm the outcome. Thanks for feedback.

Ty Abi

On Mon 3 Dec, 2018, 8:19 PM Boxuan Cui <notifications@github.com wrote:

Have you tried diagonalNetworkOutput in UI and renderDiagonalNetwork in server? These plots are sourced from networkD3 package.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/boxuancui/DataExplorer/issues/97#issuecomment-443735578, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5dW-ZbPBNRoZ-i5Q9X0UrU6EMv9c4Rks5u1TnkgaJpZM4Y9jNR .

aagarw30 commented 5 years ago

Hello,

I tried the recommendation however still not showing up the plot in the app. Could you please review and help?

Updated and reproducible code as follows:

library(shiny)
library(DataExplorer)
library(networkD3)

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

server <- function(input, output, session) {
  output$plot <- renderDiagonalNetwork({
    plot_str(iris)
  })
}

shinyApp(ui, server)
boxuancui commented 5 years ago

I was able to run your code and see the plot.

Could you try the following?

library(shiny)
library(DataExplorer)
library(networkD3)

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

server <- function(input, output, session) {
  output$plot <- renderDiagonalNetwork({
    str_list <- plot_str(iris, print_network = FALSE)
    diagonalNetwork(str_list)
  })
}

shinyApp(ui, server)
aagarw30 commented 5 years ago

Thanks so much ! Tested and working fine now. This can be closed. Appreciate help and support in this matter. ty Abi

On Wed, Dec 5, 2018 at 9:50 PM Boxuan Cui notifications@github.com wrote:

I was able to run this code and see the plot. Could you try this?

library(shiny) library(DataExplorer) library(networkD3) ui <- fluidPage( diagonalNetworkOutput("plot") ) server <- function(input, output, session) { output$plot <- renderDiagonalNetwork({ str_list <- plot_str(iris, print_network = FALSE) diagonalNetwork(str_list) }) }

shinyApp(ui, server)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/boxuancui/DataExplorer/issues/97#issuecomment-444545785, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5dW_C1_jrq__0-j3EGoqlctLNuIh8rks5u1_I6gaJpZM4Y9jNR .

boxuancui commented 5 years ago

Thanks for using DataExplorer!