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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:53:10+00:00 2026-06-18T07:53:10+00:00

I am facing an issue while subsetting a data frame in R . Data

  • 0

I am facing an issue while subsetting a data frame in R. Data frame is att2 which has a column filter_name based upon which I want to subset. The unique values for this column are below.

unique(att2[["filter_name"]])
# [1] title             Type        Operating_System         Occasion           Brand
148 Levels: Accessories Age Antennae Art_Style Aspect_ratio ... Zoom

This shows that Brand is a value for filter_name column. But when I subset the frame using below code, it gives 0 rows as below.

att3 <- subset(att2, filter_name == 'Brand')
> att3
[1] a      b         c  filter_name
<0 rows> (or 0-length row.names)

I am not able to find out the reason. Has anyone faced this kind of issue?

  • 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-18T07:53:11+00:00Added an answer on June 18, 2026 at 7:53 am

    All that we can do is guess at what the source of your problem might be.

    Here’s my best guess: Your “filter_name” column has whitespace in it, thus you shouldn’t actually be looking for “Brand” until you strip the whitespace.

    Here’s a minimal example that reproduces your problem if my guess is correct:

    First, some sample data:

    mydf <- data.frame(Param =  c("   Brand   ", "Operating System", 
                                  "Type ", "   Brand   ", "Type ", 
                                  "Type ", "   Brand   ", "Type ", 
                                  "   Brand   "), Value = 1:9)
    unique(mydf[["Param"]])
    # [1]    Brand         Operating System Type            
    # Levels:    Brand    Operating System Type 
    
    subset(mydf, Param == "Brand")
    # [1] Param Value
    # <0 rows> (or 0-length row.names)
    

    Use print with the quote = TRUE argument to see the whitespace in your data.frame:

    print(mydf, quote = TRUE)
    #                Param Value
    # 1      "   Brand   "   "1"
    # 2 "Operating System"   "2"
    # 3            "Type "   "3"
    # 4      "   Brand   "   "4"
    # 5            "Type "   "5"
    # 6            "Type "   "6"
    # 7      "   Brand   "   "7"
    # 8            "Type "   "8"
    # 9      "   Brand   "   "9"
    

    If that happens to be your problem, then a quick gsub should fix it:

    mydf$Param <- gsub("^\\s+|\\s+$", "", mydf$Param)
    unique(mydf[["Param"]])
    # [1] "Brand"            "Operating System" "Type"  
    
    subset(mydf, Param == "Brand")
    #   Param Value
    # 1 Brand     1
    # 4 Brand     4
    # 7 Brand     7
    # 9 Brand     9
    

    You may also want to look into the strip.white argument in read.table and family which defaults to FALSE. Try re-reading in your data with strip.white = TRUE and then try your subsetting.

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

Sidebar

Related Questions

We have implemented webservice which generates xml response. I am facing issue while invoking
I am facing an issue while posting a select box data to spring controller.
I am facing an issue while trying to fetch data from GoogleAnalytics API on
I am a developer and I am facing an issue while managing table which
I'm facing a character discrepancy issue while extracting data from db tables. I've written
I am facing issue while loaidng the data in JQGrid at a later stage
i'm facing a issue while testing the DAL Library which uses LINQ to SQL
I am trying to get data out of a list,but facing some issue while
I am facing an issue while using Kendo gird with both grouping & column
I am facing issue while i load a form on ajax request. i followed

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.