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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:57:05+00:00 2026-05-27T01:57:05+00:00

I’ve been doing some logging to try and illustrate to Comcast Business the frequency

  • 0

I’ve been doing some logging to try and illustrate to Comcast Business the frequency of their service interruptions at my office. I’m logging ping response times to a file then parsing that file with R. In the log file a value of 1000 means the ping timed out. My script logs the pings every 5 seconds. So if my Comcast service is down for 30 seconds that would result in ~6 log entries with value of 1000. I’d like to parse my logs in such a way that I could create a summary table that showed when each outage started, and how long it lasted. What are some good ways to do this?

Here’s some example data from today and some graphs that illustrate my time series:

require(xts)
outFile <- "http://pastebin.com/raw.php?i=SJuMQ9rD"
pingLog <- read.csv(outFile, header=FALSE, 
     col.names = c("time","ms"), 
     colClasses=c("POSIXct", "numeric"))
xPingLog <- as.xts(pingLog$ms, order.by=pingLog$time)
outages <- subset(pingLog, ms==1000)
xOutages <- as.xts(outages$ms, order.by=outages$time)

par(mfrow=c(2,1))
plot(xPingLog)
plot(outages)
outages
  • 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-05-27T01:57:05+00:00Added an answer on May 27, 2026 at 1:57 am

    You’ve got to love Run length encoding, alias rle:

    offline <- ifelse(pingLog$ms==1000, TRUE, FALSE)
    rleOffline <- rle(offline)
    
    offlineTable <- data.frame(
        endtime = pingLog$time[cumsum(rleOffline$lengths)],
        duration = rleOffline$lengths * 5,
        offline = rleOffline$values
    )
    

    Results in:

    offlineTable
    
                  endtime duration offline
    1 2011-11-20 13:20:19     1030   FALSE
    2 2011-11-20 13:20:35        5    TRUE
    3 2011-11-20 13:24:37      240   FALSE
    4 2011-11-20 13:25:57       25    TRUE
    5 2011-11-20 13:53:28     1640   FALSE
    

    Why does this work?

    First construct a logical vector that indicates online vs. offline. ifelse is handy for this.

    offline <- ifelse(pingLog$ms==1000, TRUE, FALSE)
    

    Then use rle to calculate the run length encoding:

    rle(offline)
    Run Length Encoding
      lengths: int [1:5] 206 1 48 5 328
      values : logi [1:5] FALSE TRUE FALSE TRUE FALSE
    

    This table tells how how many runs of either TRUE or FALSE occurred, and also how long each run was. In this case, the first run was 206 periods with a value of FALSE (i.e. online for 206*5=1030 seconds.

    The final step is to use the rle information to index against the original pingLog to find the times. The extra bit of magic is to use cumsum to calculate the cumulative sum of the run-lengths. The real-world meaning of this is the index position where each run terminated.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.