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 8731309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:12:26+00:00 2026-06-13T09:12:26+00:00

I am trying to do sequence analysis using time-diary data (American Time Use Survey)

  • 0

I am trying to do sequence analysis using time-diary data (American Time Use Survey) using TraMineR in R. I have the data as SPELL data (id, start time, stop time, event) but I receive the following error when trying to convert it to STS or SPS data:

Error in as.matrix.data.frame(subset(data, , 2)) : dims [product 0] do not match the length of object [9]

I believe it has something to do with how I convert my time (as character) to date/time types. I believe TraMineR requires an POSIXlt format?

Here is a snippet of my raw data (trcode is the event)

head(atus.act.short)

     tucaseid tustarttim tustoptime trcode
1 2.00701e+13   04:00:00   08:00:00  10101
2 2.00701e+13   08:00:00   08:20:00 110101
3 2.00701e+13   08:20:00   08:50:00  10201
4 2.00701e+13   08:50:00   09:30:00  20102
5 2.00701e+13   09:30:00   09:40:00 180201
6 2.00701e+13   09:40:00   11:40:00  20102

I use strptime to convert the character strings to POSIXlt:

atus.act.short$starttime.new <- strptime(atus.act.short$tustarttim, format="%X")
atus.act.short$stoptime.new  <- strptime(atus.act.short$tustoptime, format="%X")

I also cut the ID down to only two digits

  atus.act.short$id <- atus.act.short$tucaseid-20070101070000

I end up with a new data frame as follows:

   id       starttime.new        stoptime.new trcode
1  44 2012-08-03 04:00:00 2012-08-03 08:00:00  10101
2  44 2012-08-03 08:00:00 2012-08-03 08:20:00 110101
3  44 2012-08-03 08:20:00 2012-08-03 08:50:00  10201
4  44 2012-08-03 08:50:00 2012-08-03 09:30:00  20102
5  44 2012-08-03 09:30:00 2012-08-03 09:40:00 180201
6  44 2012-08-03 09:40:00 2012-08-03 11:40:00  20102
7  44 2012-08-03 11:40:00 2012-08-03 11:50:00 180201
8  44 2012-08-03 11:50:00 2012-08-03 12:05:00  20102
9  44 2012-08-03 12:05:00 2012-08-03 13:05:00 120303
10 44 2012-08-03 13:05:00 2012-08-03 13:20:00 180704
11 44 2012-08-03 13:20:00 2012-08-03 15:20:00  70104
12 44 2012-08-03 15:20:00 2012-08-03 15:35:00 180704
13 44 2012-08-03 15:35:00 2012-08-03 17:00:00 120303
14 44 2012-08-03 17:00:00 2012-08-03 17:20:00 180701
15 44 2012-08-03 17:20:00 2012-08-03 17:25:00 180701
16 44 2012-08-03 17:25:00 2012-08-03 17:55:00  70101
17 44 2012-08-03 17:55:00 2012-08-03 18:00:00 181203
18 44 2012-08-03 18:00:00 2012-08-03 19:00:00 120303
19 44 2012-08-03 19:00:00 2012-08-03 19:30:00 110101
20 44 2012-08-03 19:30:00 2012-08-03 21:30:00 120303
21 44 2012-08-03 21:30:00 2012-08-03 23:00:00  10101
22 44 2012-08-03 23:00:00 2012-08-03 23:03:00  10201
26 48 2012-08-03 06:45:00 2012-08-03 08:15:00  10201
27 48 2012-08-03 08:15:00 2012-08-03 08:45:00 180209
28 48 2012-08-03 08:45:00 2012-08-03 09:00:00  20902
29 48 2012-08-03 09:00:00 2012-08-03 11:00:00  50101
30 48 2012-08-03 11:00:00 2012-08-03 11:45:00 120312

Then I try to create a sequence object [using library(TraMineR)]

atus.seq <- seqdef(atus.act.short, informat = "SPELL", id="id")

And I get the following error:

Error in as.matrix.data.frame(subset(data, , 2)) : dims [product 0] do not match the length of object [9]

Thoughts?

  • 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-13T09:12:27+00:00Added an answer on June 13, 2026 at 9:12 am

    I’ve managed to work around this by converting the time to minutes (following another questions on stackoverflow), making the status code a character (as.character), using seqformat, and assigning it to a time axis. The new code reads:

    atus.seq2 <- seqformat(atus.act.short2, id="id", from="SPELL", to="STS", begin = "startmin", end = "stopmin", status="trcode", process = "FALSE")

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement protein pairwise sequence alignment using Global Alignment algorithm by
I'm trying to use subprocess.Popen to construct a sequence to grab the duration of
I'm trying to play sequence of audio files in the background using AVAudioPlayer. When
I am trying to create a sequence lazily by using F#. The sequence is
I'm trying to split up a nucleotide sequence into amino acid strings using a
I'm trying to increment a sequence in sqlite3. Basically, I'm using the sequence as
I am trying to replace the character sequence &a with So I can have
I am trying to schedule a function call for a sequence of items using
I'm trying to perform some basic analysis on Lotto results :) I have a
I am trying to implement local sequence alignment in Python using the Smith–Waterman algorithm

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.