nicolas-robette / GDAtools

R package for geometric data analysis and more
https://nicolas-robette.github.io/GDAtools/
10 stars 4 forks source link

Plotting selected variables using ggaxis_variables #21

Closed janhovden closed 1 year ago

janhovden commented 1 year ago

Given an mcaobject "mcapolrom" following an speMCA on a list of video games (dummies):

head(str(spel)) 'data.frame': 489 obs. of 44 variables: $ ageofempires : Factor w/ 2 levels "0","ageofempires": 1 1 1 1 1 1 1 1 1 1 ... $ animalcrossing : Factor w/ 2 levels "0","animalcrossing": 1 1 1 1 1 1 1 1 1 1 ... $ apexlegends : Factor w/ 2 levels "0","apexlegends": 1 2 1 1 1 1 1 1 1 1 ... $ assassinscreed : Factor w/ 2 levels "0","assassinscreed": 1 1 1 1 1 1 1 1 2 1 ... $ battlefield : Factor w/ 2 levels "0","battlefield": 1 1 1 1 1 1 1 1 1 1 ...

This works fine:

v1<-c('ageofempires') ggaxis_variables(mcapolrom, axis=1, var=v1)

This does not work:

v1<-c('ageofempires','animalcrossing') ggaxis_variables(mcapolrom, axis=1, var=v1) Error in rep(1, times = nrow(df)) : invalid 'times' argument

or alternatively

Error in df$ctr : object of type 'closure' is not subsettable

or sometimes

Error in seq.default(from = 0, to = minc, by = -0.5) : wrong sign in 'by' argument

Jan Fredrik

nicolas-robette commented 1 year ago

Indeed, this is a bug, as it shows out as well with the Taste data I use in the examples. Something is missing in my code for the case of two or more (but not all) variables, I'll fix this as soon as possible, hopefully next week. Bests, Nicolas

janhovden commented 1 year ago

Thank you, Nicolas! In such cases I am always uncertain if I am 1) encountering a real issue, or that 2) I am misunderstanding the syntax,or 3) have messed-up data. Next time, I will try it on the Music data as we know that should be ok. Happy if this can be of some help. Jan Fredrik

nicolas-robette commented 1 year ago

This should be fixed now. Thanks for sharing the bug !

janhovden commented 1 year ago

Great, this works fine now! In a future update, it would also be nice to have a vlab = TRUE / FALSE function so that one can choose if one only want the categories and not the variable labels. But that is for another time - this was the important bit. Thank you again! Jan Fredrik