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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:11:26+00:00 2026-06-08T12:11:26+00:00

R Beginner here. I have a list of class references. Each class has a

  • 0

R Beginner here.

I have a list of class references. Each class has a field, “x”. I want to find the class reference which has the lowest “x” in the list.

In python I would do this:

return min(item.x for item in myList)

I’m not sure if there is specific terminology for the type of statement above (if someone knows I would like to know), but is there are way of doing a similar type of thing in R ?

If not, what would be the best way to achieve this in R ?

** Edit re. Justins comment

Here is how the list is created ..

mylist <- list()
for (i in 1:10){
    mylist <- c(mylist, MyClass$new())
}

where:

MyClass <- setRefClass("MyClass",
                        fields = list(x = "numeric"),
                        methods = list(
                           initialize = function(){
                               x <<- sample(0:100, 1)
                           }
                        )
)

Many thanks

  • 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-08T12:11:28+00:00Added an answer on June 8, 2026 at 12:11 pm

    If you want to get to the entire instance of MyClass with the lowest value of x, as opposed to just the minimum value of x (you seem to be looking for the former), consider using which.min in something like the following:

    mylist[[which.min(lapply(mylist, function(myClass) myClass$x))]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python beginner here, I have a list of lists and want to refer to
Python beginner here. I have a text file that is sorted into columns: fields
Haskell beginner here. I want to pass a type parameter with JSON, and have
all.I'm a beginner of Mysql and I have one simple question here. I want
Beginner programmer here. So bear with me. I have a simple python program. print
Rails beginner here.. I have a users resource where I implemented a callback that's
Bit of a beginner question here: Say I have a block of xml: <root>
Please help this beginner here... I have a SQL Server 2008 R2 running on
I have a question about ocaml, i'm a beginner :-) Here is an example
Beginner iOS dev here. I have a problem in my array. Im making an

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.