bluefoxr / COINr

COINr
https://bluefoxr.github.io/COINr/
Other
22 stars 7 forks source link

Reorder variables in plot_corr() #33

Closed OscarSmallenbroek closed 1 year ago

OscarSmallenbroek commented 1 year ago

Hi Will,

Currently, plot_corr() seems to order variables in alphabetical order. When doing statistical audits, we often want to present the correlations in a specific order - usually according to the pillar/sub-pillar structure. Is there any way that we could specify a customized order. Otherwise, keeping the order the between plot_corr() and the dataframe the same would also work.

Best, Oscar

bluefoxr commented 1 year ago

HI Oscar, at the moment the plots are ordered according to the index structure, although they are alphabetically ordered inside each group. E.g. from the example:

image

What order would you like exactly? The problem is that if you change the order, features such as the boxes and the grouping may not work, so this could be tricky to implement.

OscarSmallenbroek commented 1 year ago

Hi William,

Indeed, I meant ordering indicators within the index/pillar. For example, putting CO2 below Forest in your example.

It would be a nice feature to have when creating a correlation plot between elements of an aggregate (e.g. indicators within one sub-pillar or sub-pillars within one pillar) and when plotting sub-pillars with pillars and the index, like in the plot below.

plot_corr(EPI, dset = "Aggregated", iCodes  = list("ECO"),Levels = 2, flagcolours = FALSE,
          withparent= "family")

image

bluefoxr commented 1 year ago

Hi, I have added an option which lets you pass character vectors for the x and y axes ordering - see the order_as argument in plot_corr(). This should work as long as it is used carefully. Example:

coin <- build_example_coin()

plot_corr(coin, dset = "Normalised", iCodes = list("Political"), 
                order_as = list(c("IGOs", "Embs", "UNVote"), 
                                        c("Embs", "IGOs", "UNVote")))

see what you think.

bluefoxr commented 1 year ago

Obviously you need to be aware of what codes will be present on the x and y axes, so you might need to plot with the default ordering first to be sure.

bluefoxr commented 1 year ago

Presume this is fine so closing now.

OscarSmallenbroek commented 1 year ago

Yes, thanks William.

On Mon, 21 Nov 2022, 18:10 Will Becker, @.***> wrote:

Closed #33 https://github.com/bluefoxr/COINr/issues/33 as completed.

— Reply to this email directly, view it on GitHub https://github.com/bluefoxr/COINr/issues/33#event-7859521114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVZEHMJRCQZ7Q7RPSWDSEDDWJOUI3ANCNFSM6AAAAAASDRP36E . You are receiving this because you authored the thread.Message ID: @.***>