Can R create a barplot image with clickable bars to insert on a webpage?

前端 未结 1 1266
挽巷
挽巷 2021-02-06 07:14

I know how to create a barplot, and how to stick it on a webpage; e.g, using hwriteImage in the hwriter package.

What I\'d like is for each bar to be a regi

相关标签:
1条回答
  • 2021-02-06 08:08

    Have a look here, which summarises a couple of methods: rggobi and iplots. rggobi looks pretty promising, though maybe the installation looks a bit involved. iplots is only good for scatter plots.

    Some other options (I think these are strongest ones at the moment):

    googleVis

    The googleVis package interfaces with the google charts API: try demo(googleVis) and the third & fourth one are bar chart (there could be more). It has the advantage of being pretty simple to get started with, although these are not R graphics:

    df=data.frame(country=c("US", "GB", "BR"), val1=c(10,13,14), val2=c(23,12,32))
    Column <- gvisColumnChart(df)
    plot(Column)
    

    gridSVG

    The gridSVG exports the current grid graphics to an .svg file that can be included into a webpage. Unlike googleVis, it's R graphics (so you can use grid/ggplot2 which are more familiar). It looks like you may have to know some Javascript to further embellish your plots though (e.g. to animate on mouse over, you use grid.garnish(...,onmouseover=...)).

    There's some example code you can try here (The really awesome ones are here - usually clicking on the "SVG file" link will have the full interactivity/animation.) (This one is a scatterplot where the points highlight when you move your mouse over them).

    As I said - have a look at the package pages, demos, examples, etc to see which suits you.

    0 讨论(0)
提交回复
热议问题