R - d3heatmap - 订购rownames和X轴

时间:2015-07-29 19:20:39

标签: r

原始df1有3列:DiaVisitaHora。为了制作热图,我需要将其从long重新整理为wide

广角df2(来自df1)。我用:

做了一个热图
d3heatmap(df2, scale = "column", colors = "Blues")

但是:我需要

1)命令rownames:“Domingo”,“Lunes”......到“Sábado”。并将它们放在图形的左侧 2)从0到24小时订购X轴。

*我还想删除“deograms”? (我不知道如何命名这些方块,向上和向左)

enter image description here

我尝试将df1DiaHoras转换为因子。但是这对行和x轴的排序没有帮助。

df1$Dia <- factor(df$Dia,
                         levels = c("Domingo", "Lunes",
                                    "Martes","Miércoles",
                                    "Jueves","Viernes",
                                    "Sábado"), 
                         ordered = T)



df1$Hora <- factor(df1$Hora,
                         levels = c(0,1,2,3,4,5,6,
                                    7,8,9,10,11,12,
                                    13,14,15,16,17,
                                    18,19,20,21,22,
                                    23,24), 
                         ordered = T)

1 个答案:

答案 0 :(得分:1)

您可以通过在dendrogram="none"的通话中加入d3heatmap()来关闭树形编程。

要按原始顺序保留单元格,请在该调用中包含Rowv=FALSE, Colv=FALSE

所以:

d3heatmap(df2, scale = "column", colors = "Blues",
    dendrogram = "none", Rowv = FALSE, Colv = FALSE)