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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:07:06+00:00 2026-06-17T17:07:06+00:00

I have imported a CSV file with numerous dates and have use the as.Date

  • 0

I have imported a CSV file with numerous dates and have use the as.Date function to convert the date. However, when I use the the mapply function to find the earlier of two dates, I either end up with a list with dates or a numeric vector. How can I get a vector with dates?

POP.Start.final <- mapply(min, combinedOM$Cons.Start.Date.y, 
                               combinedOM$OS.Start.Date.y, 
                                MoreArgs = list(na.rm=T),SIMPLIFY=T)

This returns a numeric vector, changing to SIMPLIFY=F returns a list of dates, but I want a vector of dates.

  • 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-17T17:07:07+00:00Added an answer on June 17, 2026 at 5:07 pm

    In this specific case, I believe pmin does the trick:

    POP.Start.final <- pmin(combinedOM$Cons.Start.Date.y,
      combinedOM$OS.Start.Date.y,
      na.rm=TRUE)
    

    In the general case, SIMPLIFY=TRUE (the default) uses the utility function simplify2array to convert lists to vectors of atomic mode via as.vector. Because dates are internally stored as numeric, SIMPLIFY=TRUE will convert the list of dates to a vector of mode numeric and remove the Date class. You can set SIMPLIFY=FALSE to keep the Date class and then use do.call with c to convert the list to a vector.

    POP.Start.final <- do.call(c,mapply(min, combinedOM$Cons.Start.Date.y, 
                                   combinedOM$OS.Start.Date.y, 
                                    MoreArgs = list(na.rm=TRUE),SIMPLIFY=FALSE))
    

    Some reproducible code:

    a <- as.Date(c("2012-01-11","2012-06-30","2012-04-18"))
    b <- as.Date(c("2013-04-21","2012-03-22","2012-05-01"))
    pmin(a,b)
    #[1] "2012-01-11" "2012-03-22" "2012-04-18"
    do.call(c,mapply(min,a,b,MoreArgs=list(na.rm=TRUE),SIMPLIFY=FALSE))
    #[1] "2012-01-11" "2012-03-22" "2012-04-18"
    

    As an aside, using T and F for TRUE and FALSE is slightly worrying because T and F can be reassigned while TRUE and FALSE cannot be reassigned.

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

Sidebar

Related Questions

I have a table with 600+ columns imported from a CSV file with special
I have a very large CSV file that I imported into a sqlite table.
I have imported a csv file containing spatial area information in varchar, then converted
I have a MySQL table that I have imported from a CSV file. In
I have imported a csv file into a list with this stmt: data1 =
I have a CSV file to be imported to MYSQL database. The problem is
I have a csv file that has a date field in a format like
I have made a function in Scilab that saves data in a *.csv file,
I have a class to import data from a CSV file, and a function
I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,

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.