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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:54:04+00:00 2026-05-16T13:54:04+00:00

I have the following data frame: Date1 Date2 Date3 Date4 Date5 1 25 April

  • 0

I have the following data frame:

    Date1              Date2            Date3               Date4              Date5 
1    25 April 2005       10 May 2006   28 March 2007   14 November 2007      1 April 2008  
2    25 April 2005       10 May 2006   28 March 2007   14 November 2007      1 April 2008  
3  29 January 2008   4 December 2008    6 April 2009       1 March 2010   NA 
4  29 January 2008   4 December 2008    6 April 2009       1 March 2010   1 February 2010  
5  29 January 2008   4 December 2008    6 April 2009       1 March 2010   1 February 2010  
6  29 January 2008   4 December 2008    6 April 2009       NA             NA 

And the following vector:

   1 01/09/2004 
   2 20/03/2007 
   3 16/09/2009 
   4 16/09/2009 
   5 15/07/2008 
   6 16/09/2009

I would like to make a count of the dates in each row of the data frame that are the same or before the dates in the vector. For instance for the first row the count should be zero as all the dates are after the corresponding date in the vector.

Anyone know how this can be done?

Here is output from the dput() command so you guys can read the data into R more easily for testing (if you want to):

Dataframe:

structure(c(" 25 April 2005 ", " 25 April 2005 ", " 29 January 2008 ", 
" 29 January 2008 ", " 29 January 2008 ", " 29 January 2008 ", 
" 10 May 2006 ", " 10 May 2006 ", " 4 December 2008 ", " 4 December 2008 ", 
" 4 December 2008 ", " 4 December 2008 ", " 28 March 2007 ", 
" 28 March 2007 ", " 6 April 2009 ", " 6 April 2009 ", " 6 April 2009 ", 
" 6 April 2009 ", " 14 November 2007 ", " 14 November 2007 ", 
" 1 March 2010 ", " 1 March 2010 ", " 1 March 2010 ", " 1 March 2010 ", 
" 1 April 2008 ", " 1 April 2008 ", " 1 February 2010 ", " 1 February 2010 ", 
" 1 February 2010 ", " 1 February 2010 "), .Dim = c(6L, 5L), .Dimnames = list(
    c("1", "2", "3", "4", "5", "6"), c("Rep1", "Rep2", "Rep3", 
    "Rep4", "Rep5")))

Vector:

c("01/09/2004", "20/03/2007", "16/09/2009", "16/09/2009", "15/07/2008", 
"16/09/2009")
  • 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-05-16T13:54:05+00:00Added an answer on May 16, 2026 at 1:54 pm

    First thing : You really have to transform everything to Dates, and that can be a bit tricky. I read in the matrix as Data, and the vector as vect. Then :

    vect <- as.Date(vect,format="%d/%m/%Y")
    
    # Due to the apart nature of the Date class, the normal apply-solutions 
    # don't give the result you're looking for.
    Data <- as.data.frame(Data)
    for (i in 1:ncol(Data)){
        Data[,i] <- as.Date(Data[,i],format="%d %B %Y")
    }
    > apply(Data,2,"<=",vect)
          Rep1  Rep2  Rep3  Rep4
    [1,] FALSE FALSE FALSE FALSE
    [2,]  TRUE  TRUE FALSE FALSE
    [3,]  TRUE  TRUE  TRUE FALSE
    [4,]  TRUE  TRUE  TRUE FALSE
    [5,]  TRUE FALSE FALSE FALSE
    [6,]  TRUE  TRUE  TRUE FALSE
    
    > rowSums(apply(Data,2,"<=",vect))
    [1] 0 2 3 3 1 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table and data in SQL Server 2005: create table LogEntries
I have the following data read into R as a data frame named data_old:
I have the following question: I have data frame which looks like this. I
Say I have the following R data.frame ZZZ : ( ZZZ <- structure(list(n =
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17
I have the following data structure (a list of lists) [ ['4', '21', '1',
I have a sql table which have the following data, Id City Country ---
I have the following function that is pulling data from a database. The ajax
I have the following problem in my Data Structures and Problem Solving using Java
I have the following sql query for transforming data but is it possible to

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.