Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:01:59+00:00 2026-06-04T15:01:59+00:00

I have this data set made using write.zoo for which I used the following

  • 0

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:

 write.zoo(z, file = "y.txt", row.names=1:length(z[,1]),col.names=NULL)

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:02:01+00:00Added an answer on June 4, 2026 at 3:02 pm

    The problem is caused by the timestamp:
    the values are not quoted, and the space between the date and the time
    is incorrectly understood as a column separator.

    You can circumvent the problem by using another column separator.

    write.zoo(z, file = "y.txt", sep="\t",
      row.names=1:length(z[,1]),col.names=NULL
    )
    read.zoo("y.txt", tz="", sep="\t")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this small Java program using eclipse IDE. I have set the workspace
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB
I have a set of data, with columns x and y. This set contains
I have set up a php script to receive url data like this: http://giffgaff.liamwli.co.uk/?name=liamwli
This is the code I have: Sub Main() Dim dts As New DataSet Dim
I have a growing set of Excel spreadsheets none with the same data structure.
I have this code so I can grab the values ind the dataset before
I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this data: /blabla/blabla (abs,def) /yxz I use this regex (.*)(?:\(([^$]*)\))?\n But it
I have this data: 1, 0., 0., 1500. . . 21, 0., 2000., 1500.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.