eventReactive() library(shiny)
library(shinyRGL) # for displaying 3D plot
shinyUI(fluidPage(
titlePanel(h2("TEST")),
sidebarLayout(
sidebarPanel(
fileInput("df", label = h3("Load .txt data"), accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv')),
actionButton("threeD", label = "3D")
),
mainPanel(
tabsetPanel(
tabPanel("Data", tableOutput("cont")),
tabPanel("3D", webGLOutput("threeDPlot"))
)
)
)
))
options(rgl.useNULL=TRUE)
library(shiny)
library(shinyRGL)
library(rgl)
shinyServer(function(input, output) {
dataInput <- reactive({
validate(
need(input$df != "", label = "Data set")
)
inFile <- input$df
dfTemp <- read.table(inFile$datapath, header=FALSE, sep="")
colnames(dfTemp) <- c("x", "y", "z", "value")
dfTemp
})
output$cont <- renderTable({
dataInput()
})
eventReactive(input$threeD, {
output$threeDPlot <- renderWebGL({
clr <- dataInput()$value/max(dataInput()$value)
f <- colorRamp(c("green", "yellow", "purple", "red"))
for(i in 1:length(dataInput()$x)){
shade3d(translate3d(scale3d(cube3d(col=rgb(f(clr[i])/255), alpha=0.15),
10.0, 10.0, 2.5),dataInput()$x[i],
dataInput()$y[i],dataInput()$z[i]))
}
})
})
})
1 2 3 4
2 4 6 8
3 6 9 12
33 43 75 21
--
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/6ffcca08-70f3-45ae-b539-05a9318131a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.