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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:25:20+00:00 2026-06-15T08:25:20+00:00

I have a dataframe (data) which includes a lot of dates. I want to

  • 0

I have a dataframe (data) which includes a lot of dates. I want to lop off everything from before 1970. I can create a list of indices that are before 1970:

tmp <- which(data$data < '1970-01-01')
[1]  13446 102876 141199

and I want to create a new table that drops out those three rows. Something like:

data.after.1970 <- data[!tmp, ]

I know I could create a vector of all the incidents after 1970 and match against it with:

tmp <- which(data$data > '1970-01-01')
data.after.1970 <- data[tmp, ]

But I am wondering what syntax I would use to exclude items.

UPDATE

I finally just did this:

tmp <- which(data$data > as.Date('1970-01-01'))
data.after.1970 <- data[tmp, ]

and took a closer look at it. which(data$data < as.Date('1970-01-01')) gets three results, but nrow(data) - nrow(data.after.1970) shows that I dropped 45 rows. summary(datae$date) cleared that up:

summary(data$date)
        Min.      1st Qu.       Median         Mean      3rd Qu.         Max.         NA's 
"1933-07-01" "1989-01-25" "1992-07-09" "1992-05-03" "1996-06-10" "2006-09-14"         "42" 

Since my goal was to get a second dataset so I could compare my results if I exclude those with bad dates, I actually do want to drop those with NA values as well.

I still want to know what syntax I would use to exclude some numeric vector rather than include it.

  • 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-15T08:25:21+00:00Added an answer on June 15, 2026 at 8:25 am

    Turns out it was actually pretty simple.

    data.after.1970 <- data[-tmp, ]
    

    will create a new frame, data.after.1970 that includes all the rows from data except those which match the indexes in tmp.

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

Sidebar

Related Questions

I have a data frame full from which I want to take the last
I have a data.frame (which I melted using the melt function), from which I
I have a matrix A which I want to convert into a data.frame of
Let's assume that we have a data frame x which contains the columns job
I have a data.frame called series_to_plot.df which I created by combining a number of
I have a data frame with two qualitative variables (Q1, Q2) which are both
I have a dataframe called split2_data (actually a drop-leveled subset of a bigger data
I have a dataframe with distances df<-data.frame(site.x=c(A,A,A,B,B,C), site.y=c(B,C,D,C,D,D),Distance=c(67,57,64,60,67,60)) I need to convert this to
I have a dataframe with numeric entries like this one test <- data.frame(x =
Suppose I have a dataframe like this one: df <- data.frame (id = c(a,

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.