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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:08:11+00:00 2026-05-29T08:08:11+00:00

Suppose I have a data frame, df, that looks like: f t1 t2 t3

  • 0

Suppose I have a data frame, df, that looks like:

f t1 t2 t3
h 1  3  4
h 2  4  3
t 3  4  5
t 5  6  8

with f being a factor and $t attributes being numerical values related to time ordered events.
I could overlay time series t1 to t3 using par(new=T) and isolate by factor manually.
But I wonder if there is some way to do this with lattice, where the overlaid time series
are conditioned by the factor. So we would have two panels, with overlaid time series corresponding to conditional factors, f. Most examples I’ve seen only use one time series (vector) per factor. I also thought about using a parallel plot, but time information is lost.
I’ve also tried something like

xyplot(df$t1+df$t2+df$t3 ~seq(3) | factor(df$f))

, but it loses row sequence connections. Anyone know if this is possible?

Here’s a very crude illustration using non lattice approach.

x<-matrix(seq(12),4,3)
f<-c('a','a','b','b')
df<-data.frame(f,x)

layout(1:2); yr<-c(0,12); xr<-c(1,3);
plot(as.numeric(df[1,2:4])~seq(3),type='o',ylim=yr,xlim=xr,ylab='A')
par(new=T)
plot(as.numeric(df[2,2:4])~seq(3),type='o',ylim=yr,xlim=xr,ylab='A')

plot(as.numeric(df[3,2:4])~seq(3), type='o',ylim=yr,xlim=xr,ylab='B')
par(new=T)
plot(as.numeric(df[4,2:4])~seq(3),type='o',ylim=yr,xlim=xr,ylab='B')
  • 1 1 Answer
  • 1 View
  • 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-05-29T08:08:11+00:00Added an answer on May 29, 2026 at 8:08 am

    I added an ID variable and melted with package:reshape2

     dat
      f t1 t2 t3 ID
    1 h  1  3  4  1
    2 h  2  4  3  2
    3 t  3  4  5  3
    4 t  5  6  8  4
    datm <- melt(dat, id.vars=c("ID","f"), measure.vars=c("t1", "t2", "t3"))
    > datm
       ID f variable value
    1   1 h       t1     1
    2   2 h       t1     2
    3   3 t       t1     3
    4   4 t       t1     5
    5   1 h       t2     3
    6   2 h       t2     4
    7   3 t       t2     4
    8   4 t       t2     6
    9   1 h       t3     4
    10  2 h       t3     3
    11  3 t       t3     5
    12  4 t       t3     8
    

    Since you asked to have it “overlayed” I used the group parameter to keep the ID’s separate and the “|” operator to give you the two panels for “h” and “t”:

    xyplot(value~variable|f, group=ID, data=datm, type="b")
    

    enter image description here

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

Sidebar

Related Questions

Suppose that we have a data frame that looks like set.seed(7302012) county <- rep(letters[1:4],
Suppose I have a dataframe like this one: df <- data.frame (id = c(a,
Suppose I have a function that creates data frames. I'd like to run that
Suppose that you have a data frame with many rows and many columns. The
Suppose I have a data frame in R that has names of students in
Suppose I have a data frame like this: df <- data.frame(id = rep(c(1001:1004), each
I have an R data frame containing a factor that I want to expand
Suppose, you have a data.frame like this: x <- data.frame(v1=1:20,v2=1:20,v3=1:20,v4=letters[1:20]) How would you select
Suppose I have: R> str(data) 'data.frame': 4 obs. of 2 variables: $ datetime: Factor
Suppose I have an R data frame with columns that specify location (lat/long), height,

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.