题
我绘制组曲线,在使用GGPLOT2刻面。我想有一个平滑的应用到有足够的积分,顺利情节,但不是用很少的分图。特别是我想停止积失败时的面板中的一个仅具有1或2分。
示例:
a <- data.frame( x=1:100, y=sin(seq(0.1,10,0.1) ))
b <- data.frame( x=1:5, y=sin(seq(0.1,0.2,0.1) ))
l <- melt(list(a=a,b=b),id.vars="x")
qplot( x, value, data=l ) + geom_smooth() + facet_wrap( ~ L1 )
解决方案
尝试此
library(ggplot2)
a <- data.frame( x=1:100, y=sin(seq(0.1,10,0.1) ))
b <- data.frame( x=1:2, y=sin(seq(0.1,0.2, length = 2) ))
l <- melt(list(a=a,b=b),id.vars="x")
more_than <- function(n) {
function(df) {
if (nrow(df) > n) {
df
}
}
}
lbig <- ddply(l, "L1", more_than(5))
qplot( x, value, data=l ) + geom_smooth() + facet_wrap( ~ L1 )
qplot( x, value, data=l ) + geom_smooth(data = lbig) + facet_wrap( ~ L1 )
不隶属于 StackOverflow