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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:26:32+00:00 2026-06-07T12:26:32+00:00

I’m having a dataframe as like below. > avg_data date region AveElapsedTime 1 5/1/2012

  • 0

I’m having a dataframe as like below.

    > avg_data
            date  region AveElapsedTime
    1   5/1/2012 preprod             23
    2   5/2/2012    prod             76
    3   5/3/2012    Beta             34
    4   5/4/2012    prod             30
    5   5/5/2012    Beta             22
    6   5/6/2012 preprod             32
    7   5/7/2012    Beta             21
    8   5/8/2012    prod             44
    9   5/9/2012 preprod             45
    10 5/10/2012    Beta             23
    11 5/11/2012    prod             50
    12 5/13/2012    Beta             26
    13 5/14/2012 preprod             33
    14 5/15/2012    Beta             75
    15 5/16/2012 preprod             56
    16 5/17/2012    Beta             32
    17 5/18/2012 preprod             67
    18 5/19/2012    prod             40

When I use the cbind, it is not giving the right row numbers..

    > cbind(avg_data[avg_data$region == "preprod", "date" ], avg_data[avg_data$region == "preprod", "AveElapsedTime" ])
         [,1] [,2]
    [1,]    3   23
    [2,]   15   32
    [3,]   18   45
    [4,]    5   33
    [5,]    7   56
    [6,]    9   67

This is giving problem while plotting the graph. I’m having date as x axis and AveElapsedTime value as Y axis. Instead of starting the first plot from 5/1/2012, it is starting from 5/3/2012 and trying to plot based on the rownumber given above.

If it displays as like below, then the graph will display correctly.. Please advise..

    Rownumber AveElapsedTime
         [,1] [,2]
    [1,]    1   23
    [2,]    6   32
    [3,]    9   45
    [4,]   13   33
    [5,]   15   56
    [6,]   17   67

Here is my code.. which is working now.. Need to change the color for the lines..

    avg_data <- read.table("qes.tbl", header=T, sep=",")
    avg_data
    #        dl <- avg_data[avg_data$region == "prod", "AveElapsedTime"]
            #datel <- avg_data[avg_data$region == "prod", "date"]
    #Creating the graph pdf in the below path to give as a link in the mail
    FL <- 20120631
    file <- paste("graph", FL, "pdf", sep=".")
    plot_colors <- c("blue","red","forestgreen","black")
    pdf(file, height=4.5, width=9.5, onefile=TRUE)
    graphplot <- function(l, REG, tl, num) {
            dl <- REG[REG$region == l, tl]
            datel <- REG[REG$region == l, "date"]
            dl <- cbind(as.numeric(rownames(REG[REG$region == l, ])), REG[REG$region == l, tl])
            lines(dl, type="l", pch=2, col=plot_colors[num])
            num <- num + 1
    }
    drawGraph <- function(ab, y, z, s) {
            #Creating X axis
            x <- ab[ab$region == "Beta", z]
            y <- ab[,1]
            g_range <- range(0,x[!is.na(x)])
            plot(NA, type="l", col="orange", xlim= c(1, length(y)),  ylim=g_range,axes=FALSE, ann=FALSE)
            num=1
            sapply(unique(ab$region[ab$region]), FUN=graphplot, REG=ab, tl=z, num)
            box()
            axis(1, at=1:length(y), lab=FALSE)
            text(1:length(y), par("usr")[3] - 2, srt=45, adj=1.2, labels=y, xpd=T, cex=0.3)
            scale <- s
            axis(2, las=1, at=scale*0:g_range[2], cex.axis=0.3)
            main_title<-as.expression(z)
            #Caculationg Mean, Upper limit and lower limit using the below commands
            MEANLIMIT <- seq(length=length(y), from=mean(x), by=0)
            ULIMIT <- seq(length=length(y), from=mean(x) + 2.66*sum(abs(diff(x)))/length(x), by=0)
            LLIMIT <- seq(length=length(y), from=mean(x) - 2.66*sum(abs(diff(x)))/length(x), by=0)
            lines(MEANLIMIT, type="l", col="black")
            lines(ULIMIT, type="l", pch=2, lty=2, col="grey")
            lines(LLIMIT, type="l", pch=2, lty=2, col="black")
            title(main=main_title, col.main="red", font.main=4)
            title(xlab="Test Execution Date", col.lab=rgb(0,0.5,0))
            title(ylab="Millisecond", col.lab=rgb(0,0.5,0))
            legend("topright", g_range[2], main_title, cex=0.4, col=c("blue"), lty=1);
    }
    lab<-as.character(avg_data$date)
    AET <- avg_data$AveElapsedTime
    MTitle <- "AveElapsedTime"
    #Creating graph for Average Elapsed time
            drawGraph(avg_data, lab, MTitle, 5)
  • 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-07T12:26:33+00:00Added an answer on June 7, 2026 at 12:26 pm

    It seems like you are asking for just the rownumbers as the first column. If that is so:

    cbind(as.numeric(rownames(avg_data[avg_data$region == "preprod", ])), 
          avg_data[avg_data$region == "preprod", "AveElapsedTime" ])
    #      [,1] [,2]
    # [1,]    1   23
    # [2,]    6   32
    # [3,]    9   45
    # [4,]   13   33
    # [5,]   15   56
    # [6,]   17   67 
    

    If you also want to rename the columns in the process:

    cbind(Rownames = as.numeric(rownames(
      avg_data[avg_data$region == "preprod", ])), 
          AveElapsedTime = avg_data[avg_data$region == "preprod", 
                                    "AveElapsedTime" ])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.