nachocab / clickme

An R package to create interactive plots
257 stars 44 forks source link

‘html’ is not a valid field or method name for reference class “Points” #44

Open ghost opened 10 years ago

ghost commented 10 years ago

Hello

This is a great package however I'm trying to run your asteroids example that you posted with RShiny and I got this error ‘html’ is not a valid field or method name for reference class “Points”. I'm running chrome.. When I run the clickme function from command line it works fine...

thanks steve

Here's my session info: Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] data.table_1.9.2 rjson_0.2.13 stringr_0.6.2 knitr_1.6 yaml_2.1.11 clickme_0.4.0 ggplot2_0.9.3.1 [8] rrdf_2.0.2 rrdflibs_1.3.0 rJava_0.9-6 shiny_0.10.0 rCharts_0.4.5

nachocab commented 10 years ago

Hi, sorry for the delay. I've been putting clickme in the back burner for a while.

Is this the code you're using?

setwd("~/Downloads/stats_seminar_talk_2014") # make sure your current directory points to the folder that contains the shiny_asteroids folder
library(shiny)
library(ggplot2)
runApp("shiny_asteroids")

I just tried it again and it works for me, can you run traceback() after you get the error?

ghost commented 10 years ago

Hi Nacho

No problem... so here's the code I modified, the ggplot renders fine but the click me fires that error... I tried switching dirs... but still didn't work... In the RShiny panel, I get that error message but it does open up a new tab in chrome with the data via $show

server.R

shinyServer(function(input, output, session) { library(ggplot2) library(clickme) library(scales) asteroids_data <- read.table("../asteroids_data.txt", sep = "\t", header = TRUE) asteroids <- reactive({ slider_condition <- asteroids_data$date >= input$date[1] & asteroids_data$date <= input$date[2] & asteroids_data$distance >= input$distance[1] & asteroids_data$distance <= input$distance[2] asteroids_data[slider_condition, ] })

output$ggplot <- renderPlot({ p <- ggplot(asteroids(), aes(date, distance)) + geom_point(aes(size = diameter, color = velocity)) + scale_size(range = c(2, 20)) + theme_bw() print(p) })

output$clickme <- renderChart({ x <- asteroids() p <- clickme("points",x$date, x$distance, names = x$name, radius = rescale(x$diameter, c(1,100)), extra = list("diameter (meters)" = x$diameter, "velocity (km/s)" = x$velocity), title = "Near Earth Objects", subtitle = "(as reported by the NASA NEO group)", xlab = "Date (years)", ylab = "Distance (Lunar distances)", xlim = c(2000, 2100), ylim = c(0,5), opacity = .8, out_width = 1200, out_height = 600)$show() # you only need show() if you load this through source() return(p) })

})

ui.R

shinyUI(pageWithSidebar( headerPanel("Asteroid flybys"), sidebarPanel( sliderInput("distance", "Distance (LD)", min = 0, max = 5, step = .1, value = c(0,5)), sliderInput("date", "Year", min = 2000, max = 2100, value = c(2000,2100)) ), mainPanel( tabsetPanel( tabPanel("ggplot", plotOutput("ggplot")), tabPanel("clickme",plotOutput("clickme")) ) ) ))