GithubHelp home page GithubHelp logo

Comments (2)

timelyportfolio avatar timelyportfolio commented on June 11, 2024

So happy you are using. I have decided this year to only do paid open-source and bugfix/maintenance on CRAN submitted packages http://www.buildingwidgets.com/blog/2016/12/9/bhkisodyhvttcub1mvz10fc5ow2no2. I hope someone else will jump in to help out.

from sunburstr.

Atrebas avatar Atrebas commented on June 11, 2024

I guess something like this could do the trick.
Not fully polished, but seems to work.

library(shiny)
library(sunburstR)
library(data.table)

## Random data
N = 1e3
DT = data.table(id = 1:N,
                G1 = sample(LETTERS[1:4], N, replace = TRUE),
                G2 = sample(LETTERS[1:4], N, replace = TRUE),
                G3 = sample(LETTERS[1:4], N, replace = TRUE))

DT[, seq := paste(unlist(.SD), collapse = "-"), 
   by = id, .SDcols = c("G1", "G2", "G3")]

sequences = DT[, .N, by = seq]


## ui
ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(downloadButton("dl", label = "Download")),
    mainPanel(
      sunburstOutput("sunburst"),
      tableOutput("selection")
    )
  )
)

## server
server <- function(input,output,session){
  
  output$sunburst <- renderSunburst({
    add_shiny(sunburst(sequences))
  })
  
  selection <- reactive({
    input$sunburst_click
  })
  
  DTsub <- reactive({
    DTsub = DT[paste(selection(), collapse = "-"), on = "seq", nomatch = 0]
    validate(need(nrow(DTsub) > 0, "No match found."))
    DTsub
  }) 
  
  output$selection <- renderTable(
    DTsub()
  )
  
  output$dl <- downloadHandler(
    filename = function() {"data.csv"},
    content = function(file) {
      write.csv(DTsub(), file)
    }
  )
}

shinyApp(ui = ui, server = server)

from sunburstr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.