COPY is name of my data frame (libor interest rates fred st.lious), see the link below. Year (COPY[,15]) column is numeric, I am trying to have slider of years and filter the data on the selected years and then make a histogram of a column say ‘1 Month’ or COPY[,2].
[Click to get the raw data CSV file, and full code to get COPY dataset] (https://drive.google.com/drive/folders/1ZeSqUNfPeqkmGeVdQ_7xRTibSFKYKZmT?usp=sharing)
NOTE: Most likely the issue is in the way i returned data to dccgraph, it’s confusing how many lists do you have to put your data into before you return in R.
app$layout(
htmlDiv(list(dccRangeSlider(
id='my-range-slider',min=1987,max=2013, step=1,
marks = as.list(setNames(as.character(seq(1987, 2013, by = 1)),as.numeric( seq(1987, 2013, by = 1)))),
value=list(1990, 2013)),
htmlDiv(id='output-container-range-slider'))),
##this is just to leave gap betw figure and slider
htmlStrong("hsahdasdkjas",style = list(width= '90%',margin='auto')),
htmlP("asdakdjasjd", style = list("font-size" = "11",width= '95%',margin='auto')),
htmlDiv(list(
dccGraph(
id='basic-interactions_11', style = list( width= '90%',margin= "auto"))))
)
#Reads in callback input and prints out output below the slider
app$callback(
output(id = 'output-container-range-slider', property='children'),
params=list(input(id='my-range-slider', property='value')),
function(value) {
i = as.integer(value[1])
j = as.integer(value[2])
sprintf('You have selected [%i, %i]', i, j)
})
## This callback doesn't do what is required (filter data and hist)
app$callback(
output=list(id='basic-interactions_11', property='figure'),
params=list(input(id='my-range-slider', property='value')),
function(value) {
i = as.integer(value[1])
j = as.integer(value[2])
k = list(i,j)
COPY <- COPY[(COPY$Year >= i) & (COPY$Year <= j),]
#COPY <- COPY[COPY$Year %in% k, ]
traces = list(x=COPY[,2],name= '1 Month',type= 'histogram')
figure = list(data = traces)
return (figure)
}
)
app$run_server()