please download the file in the
https://www.box.com/s/z3tldpdykhppmivfexjl
,save it as ‘/tmp/mydata’
and run the following code
datafile="/tmp/mydata"
totalsize=file.info(datafile)$size
lines=totalsize/32
con=file(datafile,"rb")
date<-c()
data<-c()
for (i in 1:lines){
result1<-readBin(con,integer(),n=1,size=4,endian="little")
date<-c(date,result1)
result2<-round(readBin(con,double(),n=7,size=4,endian="little"),2)
data<-c(data,result2)
}
date=data.frame(matrix(date,nrow=lines,ncol=1,byrow=TRUE))
data=data.frame(matrix(round(data,2),nrow=lines,ncol=7,byrow=TRUE))
data=cbind(date,data)
names(data)<-c("date","open","high","low","close","volume","amount","reserved")
data<-data[-c(1:2),]
when you finish ,please input data in R console,
you can see long digits,
https://www.box.com/s/lxkbs96vk02p6ekdflbe

why round(data,2) can not round 2 digits?
it is so strange ,when i write the data into a csv file,open the csv file,i found it has only 2 digits!
write.csv(file="/tmp/test",data)
Joris Meys say it is bad way to grow vector in for-loops,but i find maybe in my case it is good way to do that ,if not ,how to revise it?let me see the better codes.
On the issue about growing the loop, one option is to put everything into a list if you don’t know the length of each binary vector read in (as I don’t because I have not downloaded your data nor run your code!). Once in a list you can go to a compact form after if each element read in is of the same length, or in this case if all you want is a vector, just
unlist()each list.At this point you have two lists and if you want them compact-ified into a vector do