score:1
Starting from your example dataframe df, process the data slightly to add variable year as character:
df <- df %>%
mutate(YMD = ymd(year),
year = as.character(year(YMD)))
... and do the grouping and aggregation during the composition of your plot (no need to cram your workspace with dataframelets):
library(dplyr)
## (preceding plot instructions omitted)
## ...
hc_add_series(data = df %>%
group_by(year) %>%
summarise(y = mean(value, na.rm = TRUE)) %>%
mutate(name = year, drilldown = year) #, ... other args
) %>%
hc_drilldown(allowPointDrilldown = TRUE,
series = list(
df %>%
group_by(year) %>%
summarise(drilldown_series =
list(id = first(year),
data = list_parse2(
df = .[c('year', 'value')] )
)
) %>%
pull(drilldown_series)
)
If your dataframe has a lot of columns, you might want to stack these, e.g with pivot_longer
, i. e. you narrow these columns down to two: one contains the variable name, the second its value:
library(tidyr)
df %>%
pivot_longer(cols = first_column_to_stack : last_col_to_stack,
names_to = "variable",
values_to = "value"
)
... now you can dynamically filter
the long-format dataframe by variable (and year and ...) before feeding it as plot arguments.
Source: stackoverflow.com
Related Query
- R efficient Drilldown chart with loop using Highchart
- Adding data to a highchart chart using an array with IDs
- Using an editable table with HighChart and having the chart refresh with change
- How can i draw a high chart with two labels in x coordinate using highchart
- Can't build multilevel drilldown chart using Highchart API
- Json to Chart using highchart export server with Node js module its throw error
- Highchart Column with Drilldown using MySQL
- highchart with drilldown where data for main chart and drilled down chart are from different xml files
- How to create a new Highstock chart with new Highchart and not jquery?
- Highchart Area Range chart with gradient that follows the line
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- Highcharts chart with 'datetime' xAxis - use categories on drilldown
- Create Density Heatmap Chart using Jquery with array of data
- creating a bar chart using Highcharts with React - getting an error that rendering div isn't found
- Timeline chart with highcharts using x-range with multiple stacks
- create a donut chart using highchart using jquery json object
- Using Trellis Chart with Stacked Columns in Highcharts
- using angular directive to draw highchart pie chart but when i am using it in success function it is not working
- Fire click event on a highchart column drilldown chart on clicking x axis for drill down reports
- Pie chart with drilldown not working
- Using wkhtmltopdf with highcharts shows blank chart
- Highcharts multiple column chart with drilldown, correct formatting of drilldown axes
- Change chart type with drilldown series
- Error while creating the chart using highchart
- How to grab correct highchart number in selectors using Selenium Webdriver with Python with several charts on the page?
- Highcharts - column chart with drilldown to waterfall
- how to dynamically change column chart to mirror chart using highchart
- Area spline chart using Highchart
- HighChart Sparkline Chart with dynamic data for the table
- Highchart not displaying the pie chart with Ajax data
More Query from same tag
- remove extra space/margin after navigator highstocks
- Highcharts how to enable scrollbar without setting min or max
- how to determine the width of every column series present in the chart- highhcarts
- Possible to highlight without zoom in Highcharts?
- highcharts - Adding a seperate lines between the lines in categories
- Structuring data to be sent to HighCharts in view
- Highchart tooltips formatter issue
- High Chart to High Stock
- Jquery: Dynamic binding events on a Highcharts object
- Highcharts legend item hover event?
- Highcharts x-axis not formatting right when showing only 1 datapoint
- Add picture issue when exporting Highcharts to pdf - Highcharts warning: Invalid tagName
- Exception in highcharts.js line 167
- Reading From HTML5 localstorage json, not recognizing in highcharts-ng
- Highcharts hover delay and not rendering with multiple series
- Get data from several series Highcharts
- Can I let a data value null in highcharts?
- Highcharts: how to use multiple line formats in one series?
- Customize Highchart Map's legend type and color
- Visualizing Data via Highcharts and Django-Chartit2 on App Engine
- Highcharts: Display last values from stacked chart in legend
- min-height to chart container if no data with highcharts.js
- Highcharts-ng reset zoom
- Highcharts version 6 dynamic annotations not applied when running getSVG()
- add formatter for X-axis in Highchart
- Highcharts fill in scatter plot data with 0s
- Highcharts, Safari 6 and the curious case of the vertically aligned bar chart
- How to add HighChart to Angular?
- cURL not fetching the expected POST response - error 405
- Highcharts Pie chart longer text