I have the following code which plots points and draw a line between them.
ggplot (data = subset(df, vowel == "O" & gender == "f"), aes (x = time, y = val, color = formant)) +
geom_point()+
geom_line(aes(group=interaction(formant, number)))
It produces this:
Is there a way to group these by color/line type for negative slopes vs. positive slopes of these lines?
edit:
Here is my data:
number <- c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)
formant <- c("F2", "F2", "F2", "F2", "F2", "F2", "F3", "F3", "F3", "F3", "F3", "F3")
time <- c(50, 50, 50, 99, 99, 99, 50, 50, 50, 99, 99, 99)
val <- c(400, 500, 600, 450, 550, 650, 300, 400, 500, 250, 350, 450)
I want to show movement of in the value of val
over time
grouped by formant
and number
. So when I implement the answer, it tells me I have an incompatible size, which I think has something to do with the fact that it's grouped by number.
See Question&Answers more detail:
os