It does indeed exist a ticker symbol with an equal sign in it.
Because of this the notation is going to be a little weird, but we can make it work easily:
library(quantmod)
getSymbols('JPY=X', src= 'yahoo')
#> Warning: JPY=X contains missing values. Some functions will not work if
#> objects contain missing values in the middle of the series. Consider using
#> na.omit(), na.approx(), na.fill(), etc to remove or replace them.
#> [1] "JPY=X"
EMA(`JPY=X`$`JPY=X.Close`, n = 10, na.rm = T)
#> Error in naCheck(x, n): Series contains non-leading NAs
We still get an error, but this is relative to the EMA
function, not some syntax error.
You can fix the error with using na.omit(`JPY=X`)
as suggested in the warnings.
We can also simplify our life assigning the variable to a more standard name:
JPY_Close <- na.omit(`JPY=X`$`JPY=X.Close`)
EMA(JPY_Close, n = 10)
#> EMA
#> 2007-01-01 NA
#> 2007-01-02 NA
#> 2007-01-03 NA
#> 2007-01-04 NA
#> 2007-01-05 NA
#> 2007-01-08 NA
#> 2007-01-09 NA
#> 2007-01-10 NA
#> 2007-01-11 NA
#> 2007-01-12 119.26700
#> 2007-01-15 119.47664
#> 2007-01-16 119.71543
#> 2007-01-17 119.87990
#> 2007-01-18 120.13083
#> 2007-01-19 120.32704
#> 2007-01-22 120.56212
#> ...