IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Correct error on the mapping dialogue and possibly improve the R-code? #7695

Open rdstern opened 2 years ago

rdstern commented 2 years ago

I think this may be an @anastasia-mbithe challenge?

I get the error in the following way: a) Run the initial layer - a gadm file. b) Add a second station file and plot points.
image This runs fine. c) Now I wanted to change the size of the labels - which is geom label repel. I go to that geom and make the changes.
Now it gives me an error. Here is the R-code that gives the error:

# Code generated by the dialog, Climatic Maps

stations <- data_book$get_data_frame(data_name="stations")
gadm36_RWA_2_sp <- data_book$get_data_frame(data_name="gadm36_RWA_2_sp")
last_map <- ggplot2::ggplot(data=stations, mapping=ggplot2::aes(x=V1, y=V2, label=location1)) + ggplot2::geom_sf(data=gadm36_RWA_2_sp, mapping=ggplot2::aes(fill=NAME_1)) + ggplot2::geom_point(mapping=ggplot2::aes(x=V1, y=V2)) + ggrepel::geom_label_repel(label.size=0.1, label.r=0.08) + theme_grey() + ggplot2::theme(axis.text.x=ggplot2::element_text(), legend.position="none")
data_book$add_graph(graph_name="last_map", graph=last_map, data_name="gadm36_RWA_2_sp")
data_book$get_graphs(data_name="gadm36_RWA_2_sp", graph_name="last_map")
rm(list=c("last_map", "stations", "gadm36_RWA_2_sp"))

It says it can't find the variable V1, so perhaps it is looking at the wrong layer in the graph?

rdstern commented 1 year ago

I suggest @NanyanziAlice might work on this issue and perhaps then @MeSophie could do the programming.

The mapping was a popular component of the Mozambique and Malawi workshops. The error above was avoided, through not attempting to change the label size. This should be investigated, and perhaps there should be an option on the main dialogue.

In addition the item that was most popular was to filter the 2 data frames to just, then show a single district. This could be made much easier if those filters could be on the main dialogue - both parts.

There should also be an investigation of other options, e.g. the colour of a map, etc.

We did not look at facets - usually having a facet for each station type. But let's check that this is also working nicely.

And I suggest that the legend option could also be copied to the mai9n dialogue. Particularly the option to have no legend.

MeSophie commented 1 year ago

@rdstern Please can you send us the Data or the link where we can get them to investigate on this issue? Thank You.