I made with the following code:
logmod <- lm(log(Wt)~log(Palate), data=ex0328Fitch)
summary(logmod)
plot(log(ex0328Fitch$Wt), log(ex0328Fitch$Palate), pch=c(24,21),main="Log Wt vs Palate", xlab="LogPalate",
col=c("red", "blue"), ylab="LogWt"). Before I had it separated by order with different symbols. Now I am trying to figure out basically how to add an abline through each order (the red triangles and blue circles).
I think you need to add a col aesthetic to your aes() in ggplot2. To do this, you will need a column that contains different values for each group. An example with the mpg dataset (contained in the ggplot2 package):
library(ggplot2)
ggplot(data = mpg, aes(x = displ, y = hwy, col = drv)) +
geom_point() +
geom_smooth(method=lm)
It looks like you are looking for a linear regression rather than an abline. If you really do want to plot a specific pre-determined intercept and slope, you can use geom_abline():
If you need multiple lines with a pre-determined slope and intercept, you will need to create a data frame with these parameters to be used for that layer's data (and map the columns to the slope, intercept, and col aesthetics):
Also, please post your code and data on a copy / paste friendly format, and preferably using the reprex package, if you do not know how, here is a FAQ that explains how to do it.
For example, this would be a reprex for your question
Thank you andrercs. Hey how did you get those data in the dataframes, did you manually type them in, or is there an easy r-code for that? (to extract the data from a data file I have loaded in my R console. )
Ok thanks. Yeah I looked at that and it is starting to make sense. I can't get that pasta package to load on my R though,
But my next question is, how would I fit the general model that produces parallel regression lines for the two levels of Noise? (IS this saying they are just different intercepts but same slope? How to tell r this?)