More improvements to this implementation of Heatmaps in R-Instat.
In the above plot:
a) The scales are nicer in Excel or the R-Instat pivot table than any of them in the current R-Instat. A useful quick-win would be to extend the range of scales that we can use. In particular these stay much lighter, so all the numbers can be seen.
b) The graph in Excel is in sorted order of both the farmers and the treatments. We can now do this sorting in the bar chart dialogue. Useful to add those controls here too. They might need adapting. It is not sorted on frequencies, but on a variable, see the bar chart with the data option.
c) There are margins given. That will need a bit more R here.
d) The labels automatically format the numbers - I'd like that option for our labels here.
However, in R-Instat the HeatMap dialogue doesn't work yet with the option to include multiple y-variables. It can be made to work.
Here is the code:
'''heatmap <- data_book$get_data_frame(data_name="heatmap", stack_data=TRUE, measure.vars=c("no.input","fert.1","fert.2","organic.fert","leg.2","leg.1","leg.4","leg.5","leg.3","leg.7","leg.6"))
last_graph <- ggplot2::ggplot(data=heatmap, mapping=ggplot2::aes(x=sitefm., fill=value,y=variable)) + ggplot2::geom_tile() + theme_grey()+coord_flip()
data_book$add_graph(graph_name="last_graph", graph=last_graph, data_name="heatmap")
data_book$get_graphs(data_name="heatmap", graph_name="last_graph")
rm(list=c("last_graph", "heatmap"))'''
We could:
a) Allow the x to be completed, that's the other factor.
b) Put value into the fill control. (You will see that is done with variable in some other dialogues.)
c) Generate the code where the y = variable, fill = value. as in the code above.
d) Also have a checkbox on the left with coord_flip. Call it Swap x and y. Generate coord_flip() when it is checked. (You will see that on some other dialogues.
More improvements to this implementation of Heatmaps in R-Instat. In the above plot: a) The scales are nicer in Excel or the R-Instat pivot table than any of them in the current R-Instat. A useful quick-win would be to extend the range of scales that we can use. In particular these stay much lighter, so all the numbers can be seen. b) The graph in Excel is in sorted order of both the farmers and the treatments. We can now do this sorting in the bar chart dialogue. Useful to add those controls here too. They might need adapting. It is not sorted on frequencies, but on a variable, see the bar chart with the data option. c) There are margins given. That will need a bit more R here. d) The labels automatically format the numbers - I'd like that option for our labels here.
However, in R-Instat the HeatMap dialogue doesn't work yet with the option to include multiple y-variables. It can be made to work. Here is the code: '''heatmap <- data_book$get_data_frame(data_name="heatmap", stack_data=TRUE, measure.vars=c("no.input","fert.1","fert.2","organic.fert","leg.2","leg.1","leg.4","leg.5","leg.3","leg.7","leg.6")) last_graph <- ggplot2::ggplot(data=heatmap, mapping=ggplot2::aes(x=sitefm., fill=value,y=variable)) + ggplot2::geom_tile() + theme_grey()+coord_flip() data_book$add_graph(graph_name="last_graph", graph=last_graph, data_name="heatmap") data_book$get_graphs(data_name="heatmap", graph_name="last_graph") rm(list=c("last_graph", "heatmap"))'''
We could: a) Allow the x to be completed, that's the other factor. b) Put value into the fill control. (You will see that is done with variable in some other dialogues.) c) Generate the code where the y = variable, fill = value. as in the code above. d) Also have a checkbox on the left with coord_flip. Call it Swap x and y. Generate coord_flip() when it is checked. (You will see that on some other dialogues.