[R] high-frequency data in R
Zixuan Qi
z|xu@n@q| @end|ng |rom duke@edu
Tue Nov 24 21:12:21 CET 2020
Hello,
I attach the sample data in the email and you can use the data to try my code.
My code is as follow.
library('highfrequency')
library('xts')
data=read.table("sample data.csv",header=F,skip = 1,stringsAsFactors=FALSE,sep="\t")
colnames(data)=c(" ",'SYMBOL',"PRICE","PERMNO")
id <- unique(data$PERMNO)
mydata <- data.frame()
for (i in id){
tmp <-data[data$PERMNO==i,]
row.names(tmp)=tmp[,1]
tmp=tmp[,-1]
tmp.xts <- as.xts(tmp, order.by=as.POSIXlt(rownames(tmp),format="%Y/%m/%d %H:%M"))
mydata <- rbind(mydata,tmp.xts)
}
The problem is that when I try to program tmp.xts <- as.xts(tmp, order.by=as.POSIXlt(rownames(tmp),format="%Y/%m/%d %H:%M")), then I get NaN rownames. I don't know why.
Thanks very much.
More information about the R-help
mailing list