如何修复 R 包 HH 中 Likert 数据的颜色?
How to fix color for the Likert data in R package HH?
我想根据自己的选择分配颜色;
数据
resp <- data.frame(replicate(50, sample(1:7, 100, replace=TRUE)))
resp <- data.frame(lapply(resp, factor, ordered=TRUE,
levels=1:7,
labels=c("Missing","Not Applicable","Strongly disagree","Disagree", "Neutral","Agree","Strongly Agree")))
resp = t(apply(resp,2,table))[,levels(resp[,1])]
李克特剧情
我不想使用 diverge_hcl 或 sequential_hcl。
library(HH)
myColor <- likertColor(nc=7, ReferenceZero=5)
plot.likert(resp,as.percent=TRUE,col=myColor)
我有两列额外命名为 "Missing" 和 "Not Applicable"。
我需要一个与类别相关的配色方案,例如:-
- 缺失 = "light grey"
- 不适用 = "Grey"
- 强烈反对 = "Red"
- 不同意="ligt red"
- 自然 = "White" 或 "Yellow"
- 同意="Light Blue"
- 非常同意="Blue"
是否知道如何将上述配色方案应用到我的绘图中?
简单的答案是:
myColor <- c("light gray","gray","blue","light blue","white","pink","red")
plot.likert(resp,as.percent=TRUE,col=myColor)
也可以使用十六进制的 RGB:
plot.likert(resp,as.percent=TRUE,
col=c("#E94E1B", "#F7AA4E", "#BEBEBE", "#6193CE", "#00508C"))
我想根据自己的选择分配颜色;
数据
resp <- data.frame(replicate(50, sample(1:7, 100, replace=TRUE)))
resp <- data.frame(lapply(resp, factor, ordered=TRUE,
levels=1:7,
labels=c("Missing","Not Applicable","Strongly disagree","Disagree", "Neutral","Agree","Strongly Agree")))
resp = t(apply(resp,2,table))[,levels(resp[,1])]
李克特剧情
我不想使用 diverge_hcl 或 sequential_hcl。
library(HH)
myColor <- likertColor(nc=7, ReferenceZero=5)
plot.likert(resp,as.percent=TRUE,col=myColor)
我有两列额外命名为 "Missing" 和 "Not Applicable"。 我需要一个与类别相关的配色方案,例如:-
- 缺失 = "light grey"
- 不适用 = "Grey"
- 强烈反对 = "Red"
- 不同意="ligt red"
- 自然 = "White" 或 "Yellow"
- 同意="Light Blue"
- 非常同意="Blue"
是否知道如何将上述配色方案应用到我的绘图中?
简单的答案是:
myColor <- c("light gray","gray","blue","light blue","white","pink","red")
plot.likert(resp,as.percent=TRUE,col=myColor)
也可以使用十六进制的 RGB:
plot.likert(resp,as.percent=TRUE,
col=c("#E94E1B", "#F7AA4E", "#BEBEBE", "#6193CE", "#00508C"))