could not find function "+<-"

319 Views Asked by At

I get

Error in ggplot(dfyear, aes(Years)) + geom_ribbon(aes(ymin = Low, ymax = High), : could not find function "+<-"

Years=1981:2020     
Low=runif(40,min=50,max=100)     
High=runif(40,100,200)     
ETFValue=(Low+High)/2     
dfyear=data.frame(Years,Low,High,ETFValue)          

ggplot(dfyear, aes(Years)) + 
  geom_ribbon(aes(ymin=Low,ymax=High),fill="yellow") +
  ylab=("ETF value") +       
  geom_line(aes(y=ETFValue),size=2,col="darkblue") 
2

There are 2 best solutions below

0
stefan_aus_hannover On

Change this line

ylab=("ETF value") +

to this

ylab("ETF value") +

There isn't an = sign between function name and parentheses

1
Matt B On

As a side note size is deprecated in newer versions of ggplot so you might want to use linewidth instead:

ggplot(dfyear, aes(Years)) + 
  geom_ribbon(aes(ymin=Low,ymax=High),fill="yellow") +
  ylab("ETF value") +       
  geom_line(aes(y=ETFValue),linewidth=2,col="darkblue") ## linewidth instead of size