[R] 回复: high-frequency data in R

Zixuan Qi z|xu@n@q| @end|ng |rom duke@edu
Tue Nov 24 21:20:15 CET 2020


DATE    SYMBOL  price   permno
10/1/2019 9:30  AA      93.26   24109
10/1/2019 9:31  AA      93.44   24109
10/1/2019 9:32  AA      93.44   24109
10/1/2019 9:33  AA      93.28   24109
10/1/2019 9:34  AA      93.37   24109
10/1/2019 9:35  AA      93.37   24109
10/1/2019 9:36  AA      93.33   24109
10/1/2019 9:30  AA      114.47  10138
10/1/2019 9:32  AA      114.22  10138
10/1/2019 9:33  AA      114.26  10138
10/1/2019 9:34  AA      114.27  10138
10/1/2019 9:35  AA      114.01  10138
10/1/2019 9:36  AA      114.07  10138
10/1/2019 9:37  AA      114.39  10138
10/1/2019 9:38  AA      114.32  10138
The sample data is here.
________________________________
������: Zixuan Qi
����ʱ��: 2020��11��25�� 4:12
�ռ���: r-help using r-project.org <r-help using r-project.org>
����: high-frequency data in R

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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list