I'm trying to visualise missing data with the R package VIM. I'm using R version 3.4.0 with RStudio
I've used the function aggr() but the colnames of my dataframe seem to be too long. Thus, some labels of the x axis don't appear. I would like to increase the space at the bottom of the x axis.
library(VIM)
aggr(df)
Here is my dataframe df and the plot I obtain
I've tried with par() function but it doesn't change anything.
aggr(df,mar=c(10,5,5,3))
or
par(mar=c(10,5,5,3))
g=aggr(df,plot=FALSE)
plot(g)
I can reduce the font size with cex.axis but then labels are too small.
aggr(df,cex.axis=.7)
Here is the plot with small axis labels:
I've not find a lot of examples using aggr() that's why I ask for your help. Thank you in advance.
The aggr function takes all observations across all random variables and lets us visualize missingness frequencies and missingness patterns. The margin plot takes the observations from two random variables and gives us a scatterplot along with two boxplots the boxplots allow us to evaluate the MCAR vs MAR assumptions.
It is fairly straightforward to set the margins of a graph in R by calling the par() function with the mar (for margin!) argument. For example, par(mar=c(5.1,4.1,4.1,2.1) sets the bottom, left, top and right margins respectively of the plot region in number of lines of text. Another way is by specifying the margins in inches using the mai argument:
I would like to increase the size of my margins without altering the size of my plot region. What I'm doing is: plotting my data, then querying the values of mai (margin size in inches) and fin (figure region dimension in inches). adjusting mai by one inch at bottom and left. adjusting fin by one inch for width and one inch for height.
par (mar=c (5.1,4.1,4.1,2.1) sets the bottom, left, top and right margins respectively of the plot region in number of lines of text. Another way is by specifying the margins in inches using the mai argument: par (mai=c (1.02,0.82,0.82,0.42))
I think you are looking for a graphical parameter oma
which will allow you to resize the main plot. The help reference states:
For
plot.aggr
, further graphical parameters to be passed down.par("oma")
will be set appropriately unless supplied (seepar
).
In your case you could do something like:
aggr(df, prop = T, numbers = F, combined = F,
labels = names(df), cex.axis = .9, oma = c(10,5,5,3))
Obviously, you need to play around with cex.axis
and other parameters to find out what works best for your data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With