R Likert包预设英文标签

时间:2015-03-03 10:18:59

标签: r heatmap labels preset

我正在使用Likert包。

我的情节看起来像包装产生的标准图,可以在官方的Likert包页面上看到(http://jason.bryer.org/likert/

我的问题:是否有可能影响,手动更改图例标签(热图中的“百分比”和刻度中的“百分比”和“响应”?)

library(likert)
data(pisaitems)

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


ncol(items28)


items28 <- rename(items28, c(ST24Q01 = "I read only if I have to.", ST24Q02 = "Reading is one of my favorite hobbies.", 
                         ST24Q03 = "I like talking about books with other people.", ST24Q04 = "I find it hard to finish books.", ST24Q05 = "I feel happy if I receive a book as a present.", 
                         ST24Q06 = "For me, reading is a waste of time.", ST24Q07 = "I enjoy going to a bookstore or a library.", ST24Q08 = "I read only to get information that I need.", 
                         ST24Q09 = "I cannot sit still and read for more than a few minutes.", ST24Q10 = "I like to express my opinions about books I have read.", 
                         ST24Q11 = "I like to exchange books with my friends"))



l28 <- likert(items28)
summary(l28)
plot(l28, type = "heat")

(来自Likert网站的样本,它将生成一个带有颜色键图例中百分比表达式的热图)

编辑: 我在努力:

likert.heat.plot(128) + scale_fill_hue(name="Prozent")

但它不会运行 likert.heat.plot(128)也没有运行,这很奇怪,因为

plot(128, type = "heat") 

是。我另外加载了ggplot2包

1 个答案:

答案 0 :(得分:1)

只要likert.heat.plot(..)返回类为ggplot的对象,则可以使用标准ggplot2指令对其进行处理。因此,可以通过以下方式更改图例标题:

plot(l28, type = "heat") + guides(fill=guide_legend(title="Prozent"))