2017-05-25 61 views
0

我有一個數據幀DF,現在我想用GGPLOT2功能,使直方圖我想合併兩列1,2如何爲一個數據框的多列創建直方圖?

+ geom_histogram

的數據所以,我想:

v<-c(df$column1,df$column2) 
myplot = ggplot(v) 
myplot+geom_histogram() 

我得到一個錯誤:

ggplot2 doesn't know how to deal with data of class numeric

是否有另一種方法來合併列?

我唯一的問題是,我有每年的數據,我只是想比較它而不考慮年份。用不同的話把它們全部倒在一起。

+0

我認爲你需要只是包裝v處於'''aes''':'''myplot = ggplot(AES(V))''' – rsmith54

+0

現在它說GGPLOT2不知道如何處理類不等的數據 –

+2

嘗試將v作爲數據幀,然後繪製 –

回答

0
v<-c(df$columm1,df$columm2) 
library(ggplot2) 
ggplot()+aes(v)+geom_histogram(binwidth = (0.01))+xlim(c(-0.1,0.1))+labs(x="Jahresuberschuss",y="count")` 
相關問題