[R] non-numeric argument to binary operator problem in stock analysis

Lukehong kehonglu at hotmail.com
Fri Apr 22 17:47:22 CEST 2016


I use these codes to get the returns of my simulated portfolio
but, I can not get returns as the non-numeric argument to binary operator problem in stoc
thank you guys first.
library(quantmod)library(quadprog)library(stockPortfolio)library(fPortfolio)library(tseries)source("efficientFrontierFunction.r")
myenv <- new.env()##Calculate the mean and sd of the monthly returns of each stocksPotf <- c('IBM', 'KO', 'C', 'TSLA', 'F')getSymbols(Potf, from="2011-01-01", env=myenv)ts<-do.call(merge,eapply(myenv, Ad))
#we allocate equal weights to every stocksstocks <- c('IBM'=.20, 'KO'=.20, 'C'=.20, 'TSLA'=.20, 'F'=.20)#get Monthly Expected Return and Standard Deviationreturns <-getReturns(names(stocks),freq = "month",start = "2011-01-01")
 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-help mailing list