0
votes

I'm trying to ignore some 0 on a plot but I'm not finding a way to do it. i tried to use filter and which but I obtain the error "Aesthetics must be either length 1 or the same as the data (1980): y"enter image description here

above there is the code I'm using.

ggplot(data=PRICE_MSCI_MODEL_10_PAESI,aes(x=t,y=fitted_values99,group = 1))+

  • geom_line(color = "steelblue")+
  • geom_point(aes(x=t,y=which(D99!=0),colour="red"))+
  • facet_wrap(~id) Errore: Aesthetics must be either length 1 or the same as the data (1980): y
1

1 Answers

0
votes

Try to filter your data beforehand:

new_df <- PRICE_MSCI_MODEL_10_PAESI[PRICE_MSCI_MODEL_10_PAESI$D99 != 0, ]
ggplot(data = new_df, aes(...

Alternatively, you cant enter this directly into ggplot():

ggplot(data = PRICE_MSCI_MODEL_10_PAESI[PRICE_MSCI_MODEL_10_PAESI$D99 != 0, ], aes(...