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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:48:47+00:00 2026-05-23T21:48:47+00:00

I am an R neophyte, with a data frame of database function runtimes with

  • 0

I am an R neophyte, with a data frame of database function runtimes with the following data:

> head(data2)
              dbfunc runtime
1 fn_slot03_byperson  38.083
2 fn_slot03_byperson  32.396
3 fn_slot03_byperson  41.246
4 fn_slot03_byperson  92.904
5 fn_slot03_byperson 130.512
6 fn_slot03_byperson 113.853

The data has data for 127 discrete functions comprising of some 1940170 rows.

I would like to:

  1. Summarise the data to only include database functions with a mean runtime of over 100 ms
  2. Produce boxplots of the 25 slowest database functions showing the distribution of runtimes, sorted by slowest first.

I’m particularly stumped by the summary step.

Note : I’ve also asked this questions at stats.stackexchange.com.

  • 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-23T21:48:48+00:00Added an answer on May 23, 2026 at 9:48 pm

    Here’s one approach using ggplot and plyr. The steps you outlined could be combined to be slightly more efficient, but for learning purposes I’ll show you the steps as you asked them.

    #Load ggplot and make some fake data
    library(ggplot2)
    dat <- data.frame(dbfunc = rep(letters[1:10], each = 100)
                      , runtime = runif(1000, max = 300))
    
    #Use plyr to calculate a new variable for the mean runtime by dbfunc and add as 
    #a new column
    dat <- ddply(dat, "dbfunc", transform, meanRunTime = mean(runtime))
    
    #Subset only those dbfunc with mean run times greater than 100. Is this step necessary?
    dat.long <- subset(dat, meanRunTime > 100)
    
    
    #Reorder the level for the dbfunc variable in terms of the mean runtime. Note that relevel
    #accepts a function like mean so if the subset step above isn't necessary, then we can simply
    #use that instead.
    dat.long$dbfunc <- reorder(dat.long$dbfunc, -dat.long$meanRunTime)
    
    #Subset one more time to get the top *n* dbfunctions based on mean runtime. I chose three here...
    dat.plot <- subset(dat.long, dbfunc %in% levels(dbfunc)[1:3])
    
    #Now you have your top three dbfuncs, but a bunch of unused levels hanging out so let's drop them
    dat.plot$dbfunc <- droplevels(dat.plot$dbfunc)
    
    #Plotting time!
    ggplot(dat.plot, aes(dbfunc, runtime)) + 
      geom_boxplot()
    

    Like I said, I feel a few of those steps could be combined and made more efficient, but wanted to show you the steps as you outlined them.

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

Sidebar

Related Questions

Given code like this from a node.js neophyte like me: require('http').createServer(function( req, resp )
A bit of a neophyte haskell question, but I came across this example in
I'm still a neophyte Python programmer and I'm trying to do something that is
I think this is a moderately neophyte question. I've been using NHibernate/FluentNHibernate for about
I apologize for the silliness of the question but am a complete neophyte with
I am a neophyte of opencv. I should perform operations for a project involving
Complete and utter neophyte to Objective-C and the entire Mac platform so don't flame
As a neophyte clojurian, it was recommended to me that I go through the
I'm still a neophyte when it comes to SQL queries, so I was hoping
Generally, I'm still very much a unit testing neophyte. BTW, you may also see

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.