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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:53:46+00:00 2026-06-16T01:53:46+00:00

I have a dataframe for which I’ve calculated and added a difftime column: name

  • 0

I have a dataframe for which I’ve calculated and added a difftime column:

    name   amount   1st_date   2nd_date  days_out
    JEAN  318.5 1971-02-16 1972-11-27  650 days
 GREGORY 1518.5       <NA>       <NA>   NA days
    JOHN  318.5       <NA>       <NA>   NA days
  EDWARD  318.5       <NA>       <NA>   NA days
  WALTER  518.5 1971-07-06 1975-03-14 1347 days
   BARRY 1518.5 1971-11-09 1972-02-09   92 days
   LARRY  518.5 1971-09-08 1972-02-09  154 days
   HARRY  318.5 1971-09-16 1972-02-09  146 days
   GARRY 1018.5 1971-10-26 1972-02-09  106 days

I want to break it out and take subtotals where days_out is 0-60, 61-90, 91-120, 121-180.

For some reason I can’t even reliably write bracket notation. I would expect

members[members$days_out<=120, ] to show just Barry and Garry, but I get a whole lot of lines like:

NA.1095     <NA>     NA       <NA>       <NA>  NA days
NA.1096     <NA>     NA       <NA>       <NA>  NA days
NA.1097     <NA>     NA       <NA>       <NA>  NA days

Those don’t exist in the original data. There’s no one without a name. What am I doing wrong here?

  • 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-16T01:53:48+00:00Added an answer on June 16, 2026 at 1:53 am

    This is standard behavior for < and other relational operators: when asked to evaluate whether NA is less than (or greater than, or equal to, or …) some other number, they return NA, rather than TRUE or FALSE.

    Here’s an example that should make clear what is going on and point to a simple fix.

    x <- c(1, 2, NA, 4, 5)
    x[x < 3]
    # [1]  1  2 NA
    x[x < 3 & !is.na(x)]
    # [1] 1 2
    

    To see why all of those rows indexed by NA‘s have row.names like NA.1095, NA.1096, and so on, try this:

    data.frame(a=1:2, b=1:2)[rep(NA, 5),]
    #       a  b
    # NA   NA NA
    # NA.1 NA NA
    # NA.2 NA NA
    # NA.3 NA NA
    # NA.4 NA NA
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have python pandas dataframe, in which a column contains month name. How can
I have a dataframe which includes a column that has a list. When I
I have a dataframe of which the columns contain a variable amount of numbers
I have a pandas dataframe in which one column of text strings contains comma-separated
I have a dataframe called prices_df to which I add an extra column and
I have a dataframe which contains some duplicates. I want to sum rows of
I have a dataframe(df) with a number of columns, some of which contain categorical
I have a dataframe with two columns each of which represents an organism. They
I have a dataframe with 100 variables, of which I would like a subset,
I have a column in a pandas DataFrame that I would like to split

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.