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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:16:58+00:00 2026-06-13T20:16:58+00:00

I want to conditionally subset a dataframe without referencing the dataframe. For example if

  • 0

I want to conditionally subset a dataframe without referencing the dataframe. For example if I have the following:

long_data_frame_name <- data.frame(x=1:10, y=1:10)

I want to say:

subset <- long_data_frame_name[x < 5,]

But instead, I have to say:

subset <- long_data_frame_name[long_data_frame_name$x < 5,]

plyr and ggplot handle this so beautifully. Is there any package that makes subsetting a data frame similarly beautiful?

  • 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-13T20:16:59+00:00Added an answer on June 13, 2026 at 8:16 pm

    It sounds like you are looking for the data.table package, which implements indexing syntax just like that which you describe. (data.table objects are essentially data.frames with added functionality, so you can continue to use them almost anywhere you would use a “plain old” data.frame.)

    Matthew Dowle, the package’s author, argues for the advantages of [.data.table()‘s indexing syntax in his answer to this popular SO [r]-tag question. His answer there could just as well have been written as a direct response to your question above!

    Here’s an example:

    library(data.table)
    long_data_table_name <- data.table(x=1:10, y=1:10) 
    
    subset <- long_data_table_name[x < 5, ]
    subset
    #    x y
    # 1: 1 1
    # 2: 2 2
    # 3: 3 3
    # 4: 4 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to put a conditional breakpoint in windbg. For example lets say LoadLibrary
I want to conditionally call update statement on sqldatasource. I have a gridview and
I want to conditionally render my html. I have a variable by name addr_2
I have a div that is scrollable that I want to conditionally stop scrolling.
I want to conditionally switch on/off certain functionality in my Rails app, for example
I have a dataframe df. I want to create two subsets (a & b)
I have a Silverlight control in MOSS (Sharepoint 2007) which I want to conditionally
I have a LINQ expression that joins two tables. I want to conditionally check
I want to compile code conditionally based on a macro. Basically I have a
I have a jQuery UI Dialog containing some checkboxes. I want to conditionally set

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.