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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:17:05+00:00 2026-06-06T10:17:05+00:00

I know the title makes this sound very easy, but I have a For

  • 0

I know the title makes this sound very easy, but I have a For loop that graphs my data. As the values vary, so too does the limits of the X-axis (different start and end for each plot). However, I want to have a defined X-axis range that stays the same for all similar plots. This is complicated by the fact that there are ~40 possible ranges for the X that I want.

I have a data frame of the x-lims I would like to choose from, for each plot. It basically looks like:

   Trait  start    end
    A     123456   134567
    B     234546   245678
    C     234546   245678
    D     345678   356789

and so on. So, if one loop gives me the values: Trait C, start = 235000 and end = 240000, I would like to automatically use the third set of default X-lims.

edit: added more info (Trait).

  • 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-06T10:17:07+00:00Added an answer on June 6, 2026 at 10:17 am

    If your displayed data.frame is called df (and your are sure your variable end will be greater than start), this should work:

    which(start > df$start & end < df$end)[1]
    

    Revised to answer revised question

    As you add more conditions, you can extend the logic above:

    ## Make your data easily reproducible for others
    df <- read.table(text="Trait  start    end
        A     123456   134567
        B     234546   245678
        C     234546   245678
        D     345678   356789", header=TRUE)
    
    ## Set values from within your example loop
    Trait <- "C"
    start <- 235000
    end <- 240000
    
    ## Get index of desired row
    i <- which(Trait==df$Trait & start > df$start & end < df$end)[1]
    ## Extract xlim values in the form of a numeric vector
    myxlim <- unname(unlist(df[i, c("start", "end")]))
    myxlim
    [1] 234546 245678
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that the title may sound absurd, but I don't know ho to
I know that the title might sound a little contradictory, but what I'm asking
I don't know which title I should use for this question. I have a
Sorry about the title to this question, it's not very clear but wasn't sure
The title makes this sound much simpler than it is.. I'm trying to broadcast
Sorry if my title makes no sense but this is what I've gotten down
I don't know if the title makes sense, but I am wondering how a
Ok, the title may sound a little weird, but I think that kinda describe
I know this question will sound like a from the past thing but I
I know the title is somewhat confusing, my problem is this: I want to

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.