I was coding in shiny with the rgl
and shinyRGL
package, trying to plot a 3D line plot by having the users insert a csv
file of a specific format. But the object type closure error keeps showing up. It seems like because it can't find the function plot3d
, or I may be wrong.
Here's the code:
UI
library(shiny)
library(rgl)
library(shinyRGL)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
titlePanel("title panel"),
sidebarLayout(
sidebarPanel(
helpText("Please select a CSV file with the correct format."),
tags$hr(),
fileInput("file","Choose file to upload",accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv',
label = h3("File input"))
),
tags$hr(),
checkboxInput('header', 'Header', TRUE),
actionButton("graph","PLOT!")
),
mainPanel(textOutput("text1"),
webGLOutput("Aplot")))
)
)
Server
library(shiny)
library(rgl)
library(shinyRGL)
options(shiny.maxRequestSize = 9*1024^2)
shinyServer(
function(input, output) {
output$text1 <- renderText({
paste("You have selected", input$select)
})
output$"Aplot" <- renderWebGL({
inFile <- reactive(input$file)
theFrames <- eventReactive(input$graph,read.csv(inFile$datapath,
header = input$header))
plot3d(theFrames[[4]],theFrames[[5]],theFrames[[6]],xlab="x",ylab="y",zlab
= "z", type = "l", col = ifelse(theFrames[[20]]>0.76,"red","blue"))
})
})
Error
Warning: package hinyRGL?was built under R version 3.3.1 Warning: Error in [[: object of type 'closure' is not subsettable Stack trace (innermost first): 70: plot3d 69: func [C:\Users\Ian\workspace\Copy of Leap SDK/Test\App_1/server.R#19] 68: output$Aplot 1: runApp