2013-03-13 10 views
19

Ich habe die Frage schon gesehen ... und gelöst stat = "identity" zu geom_bar hinzugefügt. Aber in meinem Fall löst das nichts (ich bekomme immer noch die Meldung "keine Ebenen in der Handlung").ggplot2 Fehler "keine Ebenen in der Handlung"

MonthNB StationNAME  Ptot 
    1  stationA 21.70625 
    2  stationA 16.19375 
    3  stationA 16.64688 
    4  stationA 27.37813 
    5  stationA 38.26774 
    6  stationA 52.91250 
    7  stationA 69.36875 
    8  stationA 43.18125 
    9  stationA 33.24688 
    10  stationA 35.74839 
    11  stationA 36.01333 
    12  stationA 30.24194 
    1 stationB 25.14242 
    2 stationB 18.62121 
    3 stationB 22.11818 
    4 stationB 32.70909 
    5 stationB 33.83750 
    6 stationB 63.65937 
    7 stationB 69.05312 
    8 stationB 50.70606 
    9 stationB 46.96364 
    10 stationB 50.28710 
    11 stationB 46.81935 
    12 stationB 39.88750 

Ich habe versucht, plotten Ptot = f (MonthNB) mit:

I mit 2 Faktoren (MonthNB und Stationsname) und eine numerische Variable (PEL) ein einfaches data.frame (data3) bekam

d <- ggplot(data=data3, aes(x=MonthNB, y=Ptot, colour=StationNAME)) 
d + geom_line() 
d 

Antwort

31

Die Fehlermeldung beruht darauf, dass Sie d+geom_line() nicht als Objekt gespeichert haben.

#Save ggplot() as object 
d <- ggplot(data=data3, aes(x=MonthNB, y=Ptot, colour=StationNAME)) 

#Add to d geom_line() - this makes the plot to appear on the screen but not saved. 
d + geom_line() 

zu speichern Schicht

d<-d+geom_line() 
#No error message 
d 
+0

OK danke ... endlich, es war ein R Syntaxfehler! – user2165907

3

der Fehler war zu widersprechen, weil die geom_line() oder geom_point (Option) nicht zugegeben wurde. Sie können es direkt grafisch darstellen, ohne es beim Hinzufügen dieser Option als Objekt zu speichern.