I am new here and looking at many answers I have managed to create the following plot that displays the correlation plot of 5 variables, however, I need to modify my code so that it plots the correlations of 7 variables. Can you help me?
My code looks like this at the moment:
`n<-length(variables)
li <- lapply(1:(n^2), function(i) make_ccf(variables[(i-1)%%n+1], variables[ceiling(i/n)], with_title = F))
Create list of plots
p_dummy <- ggplot() + theme_minimal()
pl<- list(li[[2]],li[[3]],li[[4]],li[[5]], p_dummy,li[[8]],li[[9]],li[[10]],p_dummy, p_dummy,li[[14]],li[[15]], p_dummy,p_dummy,p_dummy,li[[20]])
Create row and column titles
col.titles = variables[-n]
row.titles = variables[-1]
Add row titles
pl[1:(n-1)] = lapply(1:(n-1), function(i) arrangeGrob(pl[[i]], left=row.titles[i]))
Add column titles and lay out plots
p <- grid.arrange(grobs=lapply(c(1,5,9,13), function(i) {
arrangeGrob(grobs=pl[i:(i+3)], top=col.titles[i/4 + 1], ncol=1)
}), ncol=(n-1))`
Thanks!