Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Problems passing columns between layers for reactive dataset #453

Open
zlskidmore opened this issue Mar 17, 2016 · 1 comment
Open

Problems passing columns between layers for reactive dataset #453

zlskidmore opened this issue Mar 17, 2016 · 1 comment

Comments

@zlskidmore
Copy link

When passing a mapping column from a reactive dataset (via shiny) into ggvis an error occurs saying that the object (mapping column) is not found, here is an example:

shiny server

shinyServer(function(input, output){

    # set up reactive data
    selectedData <- reactive({
        mtcars$multiply_mpg <- mtcars$mpg * input$multiply
        mtcars$id <- 1:nrow(mtcars)
        return(mtcars)
    })

    # set up hover display
    display <- function(x){
        if(is.null(x)) return(NULL)
        tmp <- selectedData()
        return_val <- tmp[tmp$id == x$id, 1]
        return(return_val)
    }

    #set up ggvis
    selectedData %>% ggvis(x=~cyl, y=~multiply_mpg, key := ~id) %>% layer_boxplots() %>%
    layer_points() %>%
    add_tooltip(display, "hover") %>%
    bind_shiny("ggvis")
})

shiny ui

library(shiny)
library(ggvis)

shinyUI(

fluidPage(
    sidebarPanel(numericInput('multiply', 'multiply mpg', 2, min = 0, max = 100)),
    mainPanel(ggvisOutput("ggvis"))
    )
)

run shiny app with ggvis input

shiny::runApp()

warning produced is:
Warning: Error in eval: object 'id' not found
Stack trace (innermost first):
107: eval
106: eval
105: prop_value.prop_variable
104: FUN
103: lapply
102: apply_props.data.frame
101: apply_props
100: eval
99: eval
98: do_.grouped_df
97: do_
96: dplyr::do
95: apply_props.grouped_df
94: apply_props
93: reactive reactive({
apply_props(parent_data(), props)
})
82: data_table[[id]]
75: shiny::isolate
74: FUN
73: lapply
72: static_datasets
71: as.vega.ggvis
70: as.vega
69: reactive reactive({
as.vega(visf(), session = session, dynamic = TRUE, ...)
})
58: r_spec
51: shiny::isolate
50: exec_connectors
49: bind_shiny
48: function_list[[k]]
47: withVisible
46: freduce
45: _fseq
44: eval
43: eval
42: withVisible
41: %>%
40: server [/Users/zskidmor/Desktop/test/server.R#21]
1: shiny::runApp
Error in eval(expr, envir, enclos) : object 'id' not found

placing "key := ~id" inside layer_points() fixes the issue but is this expected? Intuitively I would think that placing a mapping id in ggvis() would be passed to all subsequent layers.

@n0wh3r3m4n
Copy link

I know its quite old, but I'm running with the same problem and have not been able to figure it out... did you ever manage to find a solution? Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants