Unable to make a filter slider of R with crosstalk

115 Views Asked by At

I am attempting to create a slider for the date on the Big Mac Adjusted Index from https://github.com/TheEconomist/big-mac-data/releases/tag/2022-07. The error is in bscols function on R and reads as followed;"Error in sharedData$data(withKey = TRUE) : attempt to apply non-function In addition: Warning message: Unknown or uninitialised column: data.". Relevent code is below

#Packages needed
library(sf)
library("rnaturalearth")
library("rnaturalearthdata")
library(leaflet)
library(leaflet.extras)
library(tidyverse)
library(readr)
library(crosstalk)
#Takes away the scientific notation when transfered
options(scipen = 999)
#Datasets
big_mac_adjusted_index <- read_csv("C:/Users/19152/OneDrive/Desktop/Final2022FallRavina/FinalDataSet/big-mac-adjusted-index.csv")
      #Rounded data sheet to the nearest hundredth 
rBMI <- big_mac_adjusted_index %>% mutate_if(is.numeric, ~round(.,2))

#Map
map_data("world")
world <- ne_countries(scale = "medium", returnclass = "sf")
world_mac <- left_join(x = world, y = big_mac_adjusted_index[1:56,], by="iso_a3")
world_mac.sf <- st_as_sf (world_mac, crs=4326)
world_mac.sf <- st_transform(world_mac, crs=4326)
main_chart<-leaflet(world_mac.sf) %>% addPolygons(fillColor=colorQuantile("YlOrRd",world_mac.sf$USD(world_mac.sf$USD), color="black",weight = 0.1)
main_chart
#Filter 
bscols(main_chart,
 filter_slider(id = "Date", 
label = "Big Mac Index by Year",             
sharedData = rBMI,  
column = ~date        
))

I am attempting to make a slider that adjustes the map by that year's data.

0

There are 0 best solutions below