I have a dataframe with 4 columns. I use two columns (x,y) to plot for x and y. Third column (group) is used for grouping. And my fourth column (cat) is not used, but I would like it to be displayed in the tooltip.

Here is my dataframe.

```
library(rCharts)
df <- data.frame(x=c(1:12,1:12),
                 y=c(0.6, 0.5, 0.3, 0.3, 0.8, 0.99, 0.6, 0.5, 0.4, 0.7, 0.6, 0.8,
                         0.4, 0.5, 0.7, 0.7, 0.2, 0.01, 0.4, 0.5, 0.6, 0.3, 0.4, 0.2),
                 group=c(rep("group1",12),rep("group2",12)))

df$cat <- c(rep(c(rep("A",6),rep("B",6)),2))

```

I use `hPlot`function from `rCharts`to create the highcharts bar column plot.

```
p <- hPlot(x = "x", y = "y", data = df, type = c("column"),group="group")
p$addParams(dom = "plot1")
p$tooltip(borderWidth=0,
           headerFormat="<span style='font-size: 10px'><b>{point.key}</b></span><br/>",
           followPointer=TRUE,
           followTouchMove=TRUE,
           shared = FALSE)

```

[Here](https://stackoverflow.com/questions/8514457/set-additional-data-to-highcharts-series), it explains to add the extra data to the series. Seems straight forward but I havn't been able to get it to work. I have tried all sorts of things using `toJSON` from `jsonlite` and `toJSONArray` from `RJSONIO`. But, it refuses to work. That is the first part of the problem.

The second part is to actually display the tooltip once the data is in, using formatter. The [highcharts reference](http://api.highcharts.com/highcharts#tooltip.formatter) suggests:

```
    tooltip: {
        formatter: function () {
            return 'The value for <b>' + this.x +
                '</b> is <b>' + this.y + '</b>';
        }
    }

```

How does one do this in R?

```
#idea1. maybe like this?
p$tooltip(formatter=function () {
  return 'The value for <b>' + this.x +
    '</b> is <b>' + this.y + '</b>';
})

#idea2. or like this?
p$tooltip(formatter="function () {
  return 'The value for <b>' + this.x +
    '</b> is <b>' + this.y + '</b>';
}")

#idea3. or perhaps like this?
p$tooltip(formatter=function () {
  "return 'The value for <b>' + this.x +
    '</b> is <b>' + this.y + '</b>';"
})

```

Anyway, none of them work. So, if anyone has any insights, I would like to know. Thanks a lot.

PS: The same question was posted by [someone else before](https://stackoverflow.com/questions/18086812/add-values-to-rcharts-hplot-tooltip), but doesn't have a complete answer.