3
Ich habe Daten wie folgt:ggplot glatte Linie GLM-Modell mit gegebenem Vektor von Gewichten
numbers <- structure(list(density = c(1L, 4L, 10L, 22L, 55L, 121L, 210L,
444L), females = c(1L, 3L, 7L, 18L, 22L, 41L, 52L, 79L), males = c(0L,
1L, 3L, 4L, 33L, 80L, 158L, 365L), maleProp = c(0, 0.25, 0.3,
0.181818181818182, 0.6, 0.661157024793388, 0.752380952380952,
0.822072072072072), total = c(1L, 4L, 10L, 22L, 55L, 121L, 210L,
444L)), .Names = c("density", "females", "males", "maleProp",
"total"), row.names = c(NA, -8L), class = "data.frame")
I eine glatte Linie mit glm
Methode mit total
als weight
haben will. Ich habe versucht,
ggplot(numbers, aes(density, maleProp)) + geom_point() +
stat_smooth(method = "glm",
method.args = list(family = "binomial",
type = "response",
weights = "total"))
Ich habe Fehler,
Warning message:
Computation failed in `stat_smooth()`:
formal argument "weights" matched by multiple actual arguments
Wie kann ich die glatte Linie in diesem Fall zeichnen?
I habe deinen Code ausprobiert und es hat funktioniert. Könnte es sein, dass du 'total' irgendwie anders definiert hast und den Parser dadurch verwirrst? –
[Zahiro Mor] (http://stackoverflow.com/users/4700149/zahiro-mor) :: Dies könnte die ältere Version von ggplot sein, bitte aktualisieren Sie Ihre Version von ggplot, Sie werden den gleichen Fehler. – TheRimalaya