Guest User

Untitled

a guest
Dec 10th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. >PEDATA <- readxl::read_xls()
  2.  
  3. >headers <- c("Date","PEValues","lowpeindicator","highpeindicator","inpe")
  4.  
  5. >names(PEDATA) <- c(headers)
  6.  
  7. >mktdata$PEValues <- PEDATA$PEValues
  8.  
  9. >head(mktdata)
  10.  
  11. >add.indicator(strategy.name, name = "SMA", arguments =
  12. list(x=quote(PEValues(mktdata)), n = PEs), label = SMA1)
  13.  
  14. > applyStrategy(strategy = strategy.name, portfolios = portfolio.name)
  15. Error in `colnames<-`(`*tmp*`, value = seq(ncol(tmp_val))) :
  16. attempt to set 'colnames' on an object with less than two dimensions
  17.  
  18. >has.PEValues<- function (x, which = FALSE)
  19. >{
  20. > colAttr <- attr(x, "PEValues")
  21. > if (!is.null(colAttr))
  22. > return(if (which) colAttr else TRUE)
  23. > loc <- grep("PEValues", colnames(x), ignore.case = TRUE)
  24. > if (!identical(loc, integer(0))) {
  25. > return(if (which) loc else TRUE)
  26. > }
  27. > else FALSE
  28. > }
  29. >
  30. >
  31. >
  32. > PEValues<- function (x)
  33. > {
  34. > if (has.inpe(x))
  35. > return(x[, grep("PEValues", colnames(x), ignore.case = TRUE)])
  36. > stop("subscript out of bounds: no column name containing
  37. >"PEValues"")
  38. > }
Add Comment
Please, Sign In to add comment