Regarding the attempt to use read.zoo
, the format of the first column must be specified as it differs from the default. See ?read.zoo
for proper use of that function. Also there is a vignette vignette("zoo-read")
entirely devoted to read.zoo
examples.
DF <- data.frame(Date = c("01.01.2002","01.01.2003"), TotalReturns = c(183, 183))
library(zoo)
read.zoo(DF, format = "%d.%m.%Y")
## 2002-01-01 2003-01-01
## 183 183
The function dfToZoo
provided in the question uses zoo
incorrectly (see ?zoo
to understand the arguments) and the value of the format
argument should be "%d.%m.%Y"
with an upper case Y.