r - How to combine two sjp.likert (from the sjPlot package) generated plots in one plot? -


i trying combine several plots using par function. plots generated sjplot function sjp.likert().

i use 2 example plots sjplot package , try combine them:

likert_2 <- data.frame(as.factor(sample(1:2, 500, replace=true, prob=c(0.3,0.7))),     as.factor(sample(1:2, 500, replace=true, prob=c(0.6,0.4))),     as.factor(sample(1:2, 500, replace=true, prob=c(0.25,0.75))),     as.factor(sample(1:2, 500, replace=true, prob=c(0.9,0.1))),     as.factor(sample(1:2, 500, replace=true, prob=c(0.35,0.65))))     levels_2 <- list(c("disagree", "agree"))  likert_4 <- data.frame(as.factor(sample(1:4, 500, replace=true, prob=c(0.2,0.3,0.1,0.4))),     as.factor(sample(1:4, 500, replace=true, prob=c(0.5,0.25,0.15,0.1))),     as.factor(sample(1:4, 500, replace=true, prob=c(0.25,0.1,0.4,0.25))),     as.factor(sample(1:4, 500, replace=true, prob=c(0.1,0.4,0.4,0.1))),     as.factor(sample(1:4, 500, replace=true, prob=c(0.35,0.25,0.15,0.25))))     levels_4 <- list(c("strongly disagree", "disagree", "agree", "strongly agree"))     items <- list(c("q1", "q2", "q3", "q4", "q5"))  par(mfrow=c(2,1))     sjp.likert(likert_2, legendlabels=levels_2, axislabels.y=items, orderby="neg")     sjp.likert(likert_4, legendlabels=levels_4, axislabels.y=items) 

the result r shows plots succeedingly. know how combine these kinds of plots properly?

sjp.likert returns ggplot2-objects, not base-graphics.

therefore, have use other functions par.

for example try this:

p1 <- sjp.likert(likert_2, legendlabels=levels_2, axislabels.y=items, orderby="neg") p2 <- sjp.likert(likert_4, legendlabels=levels_4, axislabels.y=items) require(gridextra) require(grid) require(ggplot2) grid.arrange(p1$plot, p2$plot, nrow = 2) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -