2016-09-01 74 views
2

我想在一個只有情節繪製多個裝有流明行:繪製多個適合的R中的基礎圖形線

library(lme4) 
fits <- lmList(Sepal.Length ~ Petal.Width | Species, data=iris) 
coefs <- data.frame(coef(fits)); names(coefs) = c("Int", "slopes") 

然後我立刻繪製所有的擬合通過ggplot:

ggplot(iris, aes(x = Petal.Width, y=Sepal.Length)) + 
    geom_point(shape=1,size = 0.5)+ 
    geom_abline(aes(intercept= Int , slope=slopes), color='grey', data=coefs) 

有人可以幫我在基本的圖形方式嗎?

enter image description here

回答

4
plot(Sepal.Length ~ Petal.Width, data = iris) 
lapply(fits, abline) 

enter image description here

+0

完美@Axeman! – Juanchi