Hi everyone,
I'm currently working on a Shiny app which requires the user to select a square in a heat map and the app retrieves the corresponding row and column information.
More specifically, I have a data frame with categorical variables X and Y and a quantitative response variable Z. I used ggplot and geom_tile() to plot a heat map with X and Y on the axes and Z as the filling variable. After displaying the heat map, I would like the user to be able to click on a square and the app stores the selected X and Y values corresponding to the selected entry in the data frame.
Related attempts:
-- The information I need is exactly like the highlighted information shown in this d3heatmap example
http://rpubs.com/jcheng/nba1 . However, I would like the app to use the selected row and column information in further analysis, and I don't know how to return the information internally instead of printing.
-- I have been able to retrieve the coordinates of the clicked point using the nearPoints() function, but I couldn't transform the coordinates back to the row and column information of the data frame.
A solution using any package (base R/ggplot2/d3heatmap...) is acceptable. I would greatly appreciate any help or suggestions!
Thanks,
Jiasen