This is related to: http://stackoverflow.com/q/21393866/271616 http://stackoverflow.com/q/21484267/271616 -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com
On Tue, Feb 4, 2014 at 6:07 PM, Jairaj Gupta <j.gu...@2012.hull.ac.uk> wrote: > Hi, > > I have done the following: > > library(foreign) > RNOM <- read.dta("Return Panel without missing.dta") > library(PerformanceAnalytics) > RNOM_list<-split(RNOM,RNOM$gvkey) > xtsList <- lapply(RNOM_list, function(x) { > attrCol <- c("conm") > numCol <- c("gvkey","prccm","trfm", "trt1m") > y <- xts(x[,numCol], as.Date(x$datadate,format="%d/%m/%Y")) > xtsAttributes(y) <- as.list(x[1,attrCol]) > y > }) > > logreturns <- lapply(xtsList, function(x) { > Return.calculate(x$prccm, method = "log") > } ) > > Now I get, xts List of logreturns and xtsList of my data. > > Can anyone please tell me, how can I merge logreturns with my original > dataframe or xtsList; and export it as a csv/excel file for further > regression analysis (after merging the file needs to look like panel data)? > > The description of variables is as follows: > datadate long %d Data Date - Security Monthly > gvkey str6 %6s Global Company Key - Security > Monthly Descriptor > conm str58 %58s Company Name > prccm double %20.0g Price - Close - Monthly > trfm double %8.0g Monthly Total Return Factor > trt1m double %8.0g Monthly Total Return > gvkeynum long %8.0g gvkeynum Global Company Key - Security > Monthly Descriptor > > The data can be downloaded from here: > https://drive.google.com/file/d/0B8usDJAPeV85ZG1MSHNDeFQtM28/edit?usp=sharing > > > Thanks & Regards, > > > Jairaj Gupta > PhD Finance Candidate > Hull University Business School > Student No. 201201551 > Mobile: 00-44-(0)7795904913 > SSRN Author: http://ssrn.com/author=1936478 > Linkedin Profile: http://www.linkedin.com/pub/jairaj-gupta/54/13a/b61 > ************************************************** > To view the terms under which this email is > distributed, please go to > http://www2.hull.ac.uk/legal/disclaimer.aspx > ************************************************** > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.