我正在尝试qplot密度数据。我的表看起来为:R ggplot2 - 按颜色按行分组的颜色图
Element1 Element2 Element2 Element4 Element5 Element5
1 1 1 1 1 1
3 5 9 5 2 1
我只想名字列的颜色,但是当我使用函数read.table [R自动改变我的名字Element2.1,Element2.2,Element5.1 Elemenet5.2。
我的代码:
dataT <- read.table("file.csv", header=T, sep="\t")
dataT.long = melt.data.frame(data=dataT)
qplot(value, color=variable, data=dataT.long, geom='density', xlim='0.8')+
guides(col = guide_legend(ncol = 4, byrow = TRUE, keywidth = 0.5, keyheight = 0.5))
编辑:
如果我有这样的表,如何通过组颜色?
Element1 Element2 Element3 Element4 Element5 Element6
Group1 Group2 Group2 Group3 Group4 Group4
1 1 1 1 1 1
3 5 9 5 2 1
尝试'read.table(“file.csv”,header = T,sep =“\ t”,check.names = F)''。 – lukeA
@lukeA如果我尝试check.names = F我得到“重复'row.names'不允许” – user3502498
我们可以有一个可重复的例子吗? –