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

  • Home
  • SEARCH
  • 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 8125467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:49:41+00:00 2026-06-06T06:49:41+00:00

I have a data frame and I want to learn how the summary generates

  • 0

I have a data frame and I want to learn how the summary generates it’s information. Specifically, how does summary generate a count for the number of elements in each level of a factor. I can use summary, but I want to learn how to work with factors better. When I try ?summary, I just get the general info. Is this impossible because it is in bytecode?

  • 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-06T06:49:43+00:00Added an answer on June 6, 2026 at 6:49 am

    What we see when you type summary is

    > summary
    function (object, ...) 
    UseMethod("summary")
    <bytecode: 0x0456f73c>
    <environment: namespace:base>
    

    This is telling us that summary is a generic function and has many methods attached to it. To see what those methods are actually called we can try

    > methods(summary)
     [1] summary.aov             summary.aovlist         summary.aspell*        
     [4] summary.connection      summary.data.frame      summary.Date           
     [7] summary.default         summary.ecdf*           summary.factor         
    [10] summary.glm             summary.infl            summary.lm             
    [13] summary.loess*          summary.manova          summary.matrix         
    [16] summary.mlm             summary.nls*            summary.packageStatus* 
    [19] summary.PDF_Dictionary* summary.PDF_Stream*     summary.POSIXct        
    [22] summary.POSIXlt         summary.ppr*            summary.prcomp*        
    [25] summary.princomp*       summary.srcfile         summary.srcref         
    [28] summary.stepfun         summary.stl*            summary.table          
    [31] summary.tukeysmooth*   
    
       Non-visible functions are asterisked
    

    Here we see all the methods associated with the summary function. What this means is that there is different code for when you call summary on an lm object than there is when you call summary on a data.frame. This is good because we wouldn’t expect the summary to be conducted the same way for those two objects.

    To see the code that is run when you call summary on a data.frame you can just type

    summary.data.frame
    

    as shown in the methods list. You’ll be able to examine it and study it and do whatever you want with the printed code. You mentioned that you were interested in factors so you will probably want to examine the output of summary.factor. Now you might notice that some of the methods printed had an asterisk (*) next to them which implies that they’re non-visible. This essentially means that you can’t just type the name of the function to try to view the code.

    > summary.prcomp
    Error: object 'summary.prcomp' not found
    

    However, if you’re determined to see what the code actually is you can use the getAnywhere function to view it.

    > getAnywhere(summary.prcomp)
    A single object matching ‘summary.prcomp’ was found
    It was found in the following places
      registered S3 method for summary from namespace stats
      namespace:stats
    with value
    
    function (object, ...) 
    {
        vars <- object$sdev^2
        vars <- vars/sum(vars)
        importance <- rbind(`Standard deviation` = object$sdev, `Proportion of Variance` = round(vars, 
            5), `Cumulative Proportion` = round(cumsum(vars), 5))
        colnames(importance) <- colnames(object$rotation)
        object$importance <- importance
        class(object) <- "summary.prcomp"
        object
    }
    <bytecode: 0x03e15d54>
    <environment: namespace:stats>
    

    Hopefully this helps you explore the code in R much more easily in the future.

    For even more details you can view Volume 6/4 of The R Journal (warning, pdf) and read Uwe Ligge’s “R Help Desk” section which deals with viewing the source code of R functions.

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

Sidebar

Related Questions

I have a data frame with several variables. What I want is create a
I have the following data: a=c(1:10) b=c(16:25) c=c(24:33) wa=c(3,7,3,3,3,3,3,3,3,1) wb=c(3,2,3,3,3,3,3,3,3,8) wc=c(4,1,4,4,4,4,4,4,4,1) z=data.frame(a,b,c,wa,wb,wc) I want
I have a data.frame with 2 columns: Node A, Node B. Each entry in
I have a data.frame called series_to_plot.df which I created by combining a number of
I have a data frame filled with factor columns, and I want to add
I have a data frame where each line represents an individual. That data frame
I have data.frame that contains several factors and i want to rename factor levels
I have a data.frame and I want to write it out. The dimensions of
I have a data frame with several rows and I want to create a
I have a data frame, and I want to do some calculation with existing

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.