On Tue, Nov 18, 2014 at 9:42 PM, Upananda Pani <upananda.pani at
gmail.com> wrote:> Dear All,
>
> I want to read the my time series data using XTS package and then to
> calculate return using PeformanceAnalytics Package but i am getting the
> following error. Please help me to solve the problem. The error follows:
>
> # Required Libraries
>> library(xts)
>> library(PerformanceAnalytics)
>>
>> #Reading Data
>> x<-read.csv('crude.csv')
>> y<-xts(x[,1:2],as.numeric(x[,2:2]),order.by
> =as.Date(x[,1],format='%d-%b-%y'))
>> close <- y$close
>>
>> #Calculating Return
>> rspot = Return.calculate(close, method = c ("discrete"))
> Error in `/.default`(pr, lag(pr)) :
> non-numeric argument to binary operator
>
>
> I am not getting where i am committing the mistake.
>
I'm not sure what you were trying to do, because:
1) You didn't provide a reproducible example (I don't have
'crude.csv'), and
2) it doesn't make sense to use unnamed arguments for the first two
arguments, and then use a named argument to re-specify the second
argument (order.by).
You probably wanted something like:
close <- xts(x[,2], as.Date(x[,1], format='%d-%b-%y'))
> With sincere regards,
> Upananda
>
> --
>
>
> You may delay, but time will not.
>
>
> Research Scholar
> alternative mail id: upani at iitkgp.ac.in
> Department of HSS, IIT KGP
> KGP
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com