not able read using read.zoo
I have this data set made using write.zoo for which I used the following code:
z <- structure(c(9.82, 9.83, 9.82, 9.9, 9.81, 9.83, 12.57, 12.57, 12.57, 12.57, 12.57, 12.57, 2.75, 2.74, 2.75, 2.67, 2.76, 2.74 ), .Dim = c(6L, 3L), .Dimnames = list(c("15", "14", "13", "12", "11", "10"), c("depth", "from_sensor_to_river_bottom", "Depth_from_river_surface_to_bottom" )), index = structure(c(1337810422, 1337811320, 1337812220, 1337813118, 1337814021, 1337814919), class = c("POSIXct", "POSIXt"), tzone = ""), class = "zoo")
So, z is a zoo object:
z depth from_sensor_to_river_bottom Depth_from_river_surface_to_bottom 15 9.82 12.57 2.75 14 9.83 12.57 2.74 13 9.82 12.57 2.75 12 9.90 12.57 2.67 11 9.81 12.57 2.76 10 9.83 12.57 2.74 attr(,"index") [1] "2012-05-23 23:00:22 BST" "2012-05-23 23:15:20 BST" "2012-05-23 23:30:20 BST" "2012-05-23 23:45:18 BST" [5] "2012-05-24 00:00:21 BST" "2012-05-24 00:15:19 BST" attr(,"class") [1] "zoo"
I write it to file using:
This is how output file "y.txt" looks like:
"Index" "depth" "from_sensor_to_river_bottom" "Depth_from_river_surface_to_bottom" "1" 2012-05-23 15:00:22 9.82 12.57 2.75 "2" 2012-05-23 15:15:20 9.83 12.57 2.74 "3" 2012-05-23 15:30:20 9.82 12.57 2.75 "4" 2012-05-23 15:45:18 9.9 12.57 2.67 "5" 2012-05-23 16:00:21 9.81 12.57 2.76
I'm trying to read it using :
read.zoo("y.txt", tz="")
Which gives me this error:
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 6 elements.
I'm not able to figure out what the problem is? And also whether the problem is with my writing to file or with reading the file?
Thank you for your consideration. I appreciate your help.
