使用Plotly R中map的event_data来渲染dataTable

时间:2016-04-24 18:00:09

标签: r shiny plotly

我需要一些帮助,使用plotly r中的event_data来渲染dataTable,而不是只显示cwrevenumber和pointNumber。

    output$plot1 <- renderPlotly({
    df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')    

    # light grey boundaries
     l <- list(color = toRGB("grey"), width = 0.5)

    # specify map projection/options
    g <- list(
      showframe = FALSE,
      showcoastlines = FALSE,
      projection = list(type = 'Mercator')
      )

      plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE, type =       'choropleth', source = 'click', color = GDP..BILLIONS., colors = 'Blues', marker =     list(line = l),
        colorbar = list(tickprefix = '$', title = 'GDP Billions US$')) %>%
  layout(title = '2014 Global GDP<br>Source:<a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">CIA World Factbook</a>',
         geo = g)
    })


output$c_locate_info <- renderDataTable({
    event.data <- event_data(event='plotly_click', source = 'click') 

    if(is.null(event.data)==T) return('Select Regions for More Details')
    })    

1 个答案:

答案 0 :(得分:1)

我想你错过了其他的&#39;参数

output$c_locate_info <- renderDataTable({
event.data <- event_data(event='plotly_click', source = 'click') 

if(is.null(event.data)==T) return('Select Regions for More Details') else d
})