R 使用ggplot2的图形

R 使用ggplot2的图形,r,ggplot2,R,Ggplot2,我在尝试使用ggplot2软件包时遇到问题。我得到的所有图表都是空的 ggplot(data=dataa,aes(x=Description, y=RPKM,fill=Condition)) + geom_bar(position="dodge",stat="identity") dataa是一个更大的数据帧,如下所示: Description Tissue Condition RPKM re brain obese 34 re1

我在尝试使用ggplot2软件包时遇到问题。我得到的所有图表都是空的

ggplot(data=dataa,aes(x=Description, y=RPKM,fill=Condition)) + 
  geom_bar(position="dodge",stat="identity")
dataa
是一个更大的数据帧,如下所示:

Description Tissue  Condition   RPKM
re           brain  obese       34
re1          brain  Fit         23
re2          brain  Slim        67
知道我做错了什么吗

我拥有的真实数据:

Description Tissue  Condition   RPKM 
peptidase Brain Obese   0.5
protein Brain   Obese   1.4 
Glucagon    Brain   Fit 0.06 
kinase  Brain   Fit 0.9 
transporter Brain   Obese   4.8 
Secretogran Brain   Slim    87.2 
脚本:

tissues<-factor(unique(RPKMl123upslim$Tissue)) 
for (n in 1:6) { 
    i=c(0,108,216,324,432,540) 
    #datos<-data.frame(RPKMl123upslim[(i[n]+1):(i[n]+108),]) 
    View(datos) 
    ggplot(data=datos,aes(x=Description, y=Expression,fill=Condition)) + 
        geom_bar(position="dodge",stat="identity", colour="black",las=2) 

    path100<-file.path("pajarito",paste("Lupslimrpkm_",tissues[n],".jpg", sep=" ")) 
    jpeg(file=path100) 
    dev.off() 
} 
组织
库(ggplot2)

dataa感谢您的帮助,现在我想与大家分享成功的代码:

 dev.set(dev.prev()) 
#dev.new(width=10, height=12)
 path100<-file.path("D:","final.results",paste("skin005",".png", sep=" "))
 png(file=path100, width=1000, height=10000, res=100)
plot(1:100)
attach(skin005RPKMS) #previous data frame with all information
q<-skin005RPKMS[(Skin.Obese > Skin.Fit) & (Skin.Obese > Skin.Slim),]
colnames(q)<-c("Description","Skin.Slim","Skin.Fit","Skin.Obese")
q1<-melt(q,id.vars="Description") #variable contain the different condition    of the experiment and value the data.
p <- ggplot(q1, aes(y=Description,x=variable))+ geom_tile(aes(fill=value)) +   scale_fill_gradientn(colours=c("white","azure2","yellow","blue","orchid","orange red","red","black"), values=rescale(c(0,1,10,50,100,500,1000,4500)),  guide="colorbar") + xlab("Condition") + ylab("Genes")
print(p)
dev.off()
dev.set(dev.prev())
#新开发(宽度=10,高度=12)
path100皮肤。苗条),]

colnames(q)哦,谢谢你的用户名2673238;但问题是我使用的是一个从文本文件导入的数据框,我不知道为什么我的图仍然是空的。嗯,你能给出一些示例数据吗?。或者弄清楚你得到的是哪种类型的数据<代码>类型(数据A$RPKM)
例如。描述组织状况RPKM肽酶脑肥胖0.5蛋白质脑肥胖1.4胰高血糖素脑适配0.06激酶脑适配0.9转运蛋白脑肥胖4.8分泌型脑瘦身87.2脚本:组织扫描你包括一些样本数据,分离并显示你的问题?当然我已经在原始问题中添加了谢谢用户2673238只是你的文件是空的吗?因为您
jpeg()
启动一个文件,而
dev.off()
关闭该文件。由于中间没有代码行,因此不能在文件中放入任何内容。如果您
print()。或者去掉
jpeg()
dev.off()
,改用
ggsave()
 dev.set(dev.prev()) 
#dev.new(width=10, height=12)
 path100<-file.path("D:","final.results",paste("skin005",".png", sep=" "))
 png(file=path100, width=1000, height=10000, res=100)
plot(1:100)
attach(skin005RPKMS) #previous data frame with all information
q<-skin005RPKMS[(Skin.Obese > Skin.Fit) & (Skin.Obese > Skin.Slim),]
colnames(q)<-c("Description","Skin.Slim","Skin.Fit","Skin.Obese")
q1<-melt(q,id.vars="Description") #variable contain the different condition    of the experiment and value the data.
p <- ggplot(q1, aes(y=Description,x=variable))+ geom_tile(aes(fill=value)) +   scale_fill_gradientn(colours=c("white","azure2","yellow","blue","orchid","orange red","red","black"), values=rescale(c(0,1,10,50,100,500,1000,4500)),  guide="colorbar") + xlab("Condition") + ylab("Genes")
print(p)
dev.off()