我如何告訴ggplot以積點只有當計數大於X更大。我知道這應該很容易,但我無法弄清楚。像GGPLOT2 geom_bar圖,其中..count ..大於X
ggplot(items,aes(x=itemname,y=..count..))+geom_bar(y>X)
我如何告訴ggplot以積點只有當計數大於X更大。我知道這應該很容易,但我無法弄清楚。像GGPLOT2 geom_bar圖,其中..count ..大於X
ggplot(items,aes(x=itemname,y=..count..))+geom_bar(y>X)
如果我正確理解你的問題(你沒有提供示例數據),最簡單的方法是生成你想要ggplot之外繪製數據幀。所以
##Example data
items = data.frame(itemname = sample(LETTERS[1:5], 30, replace=TRUE))
##Use table to count elements
items_sum = as.data.frame(table(items))
然後繪製
X = 4
ggplot(items_sum[items_sum$Freq > X,], aes(x=items,y=Freq)) +
geom_bar(stat="identity")
我可以在這裏錯了,可是你不能簡單地通過geom_bar傳遞子代碼()?
ggplot(items_sum, aes(x=items,y=Freq)) + geom_bar(stat="identity", subset=.(Freq>4))
'ggplot(項目[項目$ Y>項目$ X],...)' – Andrie