Le mardi 04 août 2015 à 06:50 -0700, Danny Zuko a écrit :
> Le jeudi 23 juillet 2015 15:16:49 UTC+2, Andreas Noack a écrit :
> > For the example you describe, you can simply use the tools in base, 
> > but unfortunately I don't think our reader can handle continental 
> > style decimal comma yet. However, that is easy to search/replace 
> > with a dot. Something like
> > 
> > cov(diff(log(readdlm("prices.csv", ';'))))
> > 
> > should then do the job.
> > 
> Let's assume we have a csv file of the following form:
> 
> "Dates","ES1 Index","VG1 Index","TY1 Comdty","RX1 Comdty","GC1 
> Comdty"
> "1999-01-04",1391.12,3034.53,66.515625,86.2,441.39
> "1999-01-05",1404.86,3072.41,66.3125,86.17,440.63
> "1999-01-06",1435.12,3156.59,66.4375,86.32,441.7
> 
> readcsv("prices.csv", header=true) does its job.
> 
> However, I won't be able to pass it to any function that performs any 
> numerical computation as all values in the first column are strings. 
> Hence, log(readcsv("prices.csv", header=true)) will return an error.
> 
> The read.csv function in R has a handy row.names arguments which - 
> when you set it equal to 1 - takes the first column of your csv file 
> as a vector of row-names. Hence, if you evaluate 
> log(read.csv("prices.csv", sep = ";", row.names=1)) you do not get 
> any error as all values are now numerical + each row keeps its own 
> row name.
> 
> As of now, the only place where I found this handy feature is the 
> readtimearray function in the TimeSeries.jl package. Is there any 
> other way in Julia to benefit from this little but handy comfort that 
> I am not yet aware of?
Not that I know of, because the concept of rownames does not exist for
Julia matrices nor for DataFrames. Regarding the former, it could make
sense as an extension of NamedArrays, though I'm not sure that package
should really offer a specific version of read.csv(). Regarding the
latter, this was a conscious decision to be closer to the structure of
databases, and calling log() on a DataFrame is no longer allowed for
similar reasons. But maybe another direct way of doing the same kind of
thing easily can be found.


Regards

Reply via email to