Variable Hline in ggplot mit Facette

Am Beispiel des Iris-Datensatzes kann ich einen ggplot mit Facette erstellen. Der Code lautet:

library(ggplot2)
data(iris)
y=iris
y$Petal.Width.Range=factor(ifelse(y$Petal.Width<1.3,"Narrow","Wide"))
y$Petal.Length.Range=factor(ifelse(y$Petal.Length<4.35,"Short","Long"))
ggplot(y, aes(Sepal.Length,Sepal.Width)) + 
  geom_point(alpha=0.5)+
  geom_hline(yintercept =3 ,alpha=0.3)+
  facet_grid(Petal.Width.Range ~ Petal.Length.Range)

Hier habe ich eine horizontale Spezifikation von 3 in jedem der 4 Fälle. Was soll ich tun, wenn ich eine fallabhängige Spezifikation möchte? Zum Beispiel kann ich 4 verschiedene Spezifikationen wie folgt definieren:

y$threshold=2
y$threshold[(y$Petal.Width.Range=="Narrow")&(y$Petal.Length.Range=="Short")] =2
y$threshold[(y$Petal.Width.Range=="Narrow")&(y$Petal.Length.Range=="Long")] =2.5
y$threshold[(y$Petal.Width.Range=="Wide")&(y$Petal.Length.Range=="Short")] =3.1
y$threshold[(y$Petal.Width.Range=="Wide")&(y$Petal.Length.Range=="Long")] =4

Wie soll ich den ggplot-Befehlen bitte y $ threshold hinzufügen?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage