I have tried to calculate the log rate of return for a world index (labled acw) portfolio and a country index portfolio (labled chi). The world index works but the country index gives me the error "only 0's may be mixed with negative subscripts". I have combed the data and there are no zeros or negative numbers in it. I'm going insane trying to work it out. I am learning R for the first time so it is probably a very basic problem but I can't find an answer anywhere online. Here is the code,
> data <- read.table("C:/Documents and Settings/Emma/My Documents/data.csv",header=T,sep=",")
> data <- data.frame(data)
> td<-length(data$date)
> t<-td-1
> acwr<-250*log(data$acw[2:td]/data$acw[1:(td-1)])
> chir<-250*log(data$chi[2:td]/data$chi[1:(td-1)])
Error in data$chi[1:(td - 1)] :
only 0's may be mixed with negative subscripts
> traceback()
No traceback available
Any advice or help would be much appreciated!