2014-12-08 86 views
1

使用likert包(更多信息:http://jason.bryer.org/likert/)創建這些使用ggplot2的圖。在框中添加百分比並添加子標題R

下面是一些示例代碼在R.

require(likert) 

data(pisaitems) 

items28 <- pisaitems[, substr(names(pisaitems), 1, 5) == "ST24Q"] 

l28 <- likert(items28) 

plot(l28) 

以使用likert的曲線下面是我想要的輸出,以顯示,而不是一個例子:

enter image description here

首先,我想在百分比中添加百分比來表示數量,而不僅僅是像當前提供的那樣。我已經瀏覽了github上的源代碼,無法理解他是如何做到這一點的。

其次,我想知道它有可能在中間的每一邊有一個小標題,在圖的上方說「非常低/低的百分比」和「高/非常高的百分比」與劇情的其餘部分相關。

感謝

回答

1

要添加,你只需要參數plot.percents設置爲TRUE百分比。我不知道副標題的一個好的解決方案,但您可以玩ggplot2包的ggtitletheme函數。這裏有一個想法:

plot(l28, plot.percents = TRUE) + 
ggtitle("Percentage of Strongly disagree/Disagree Percentage of Strongly agree/Agree") + 
theme(plot.title = element_text(hjust = 0.45, size = 10))