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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:10:24+00:00 2026-06-11T22:10:24+00:00

I have an R object called gene_table, and it has class foo . Now

  • 0

I have an R object called gene_table, and it has class foo. Now I subset this gene_table by

gene_data = gene_table[1:100,1:5]

However, when I call class(gene_data), it is no longer of class foo, but instead, it has class matrix. This is a headache for me because my method summary.foo won’t recognize this object gene_data of class matrix. I am hoping to retain the original class attribute when subsetting, so could anyone tell me how to do it? Thanks!

Update: dput(head(gene_table)) gives me

c(5.21708054951994, 5.01224214039806, 4.92160314073853, 4.83031021496, 4.78552614584879, 4.77821370665578)

and str(gene_table) gives me

 foo [1:22743, 1:2] 5.22 5.01 4.92 4.83 4.79 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:22743] "ENSG00000127954" "ENSG00000151503" "ENSG00000096060" "ENSG00000091879" ...
  ..$ : chr [1:2] "Var1" "Var2"
  • 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-11T22:10:26+00:00Added an answer on June 11, 2026 at 10:10 pm

    You could use something like this as your definition for [.foo:

    `[.foo` <- function(x, ..., drop=TRUE) {
       structure(NextMethod(), class="foo")
    }
    

    You may need to add other things, depending on the complexity of your "foo" class.

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

Sidebar

Related Questions

I have object called Foo. Right now it implements IFoo which has a lot
I have an object class called BOM. It has a method, getChildItem() which returns
How would something like this be possible: I have an object called Player: class
I have an object called LastQueryInfo lastQuery in my class. Every time this object
I have this object called Event, and event has some other linked tables. [PetaPoco.ResultColumn]
I have an object called Layer that has some attributes and some methodes. i
I have an object called Document that has a one-to-many relationship with DocumentPersonCc. I
I have an object called Contact. A Contact has a relationship with a set
I have a parent object called Page that has a List of objects called
In my JS, I have an object called box_object. It looks like 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.