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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:41:24+00:00 2026-05-25T21:41:24+00:00

I have a list of dates that I wish to sample from. Sometimes the

  • 0

I have a list of dates that I wish to sample from. Sometimes the sample space will just be a single date e.g. sample(“10/11/11”,1). The dates are stored as chron objects, so when I have just a single date in my sample space (and only then) sample treats this as a vector (1:date). The documentation for sample points this out:

 If ‘x’ has length 1, is numeric (in the sense of ‘is.numeric’) and
 ‘x >= 1’, sampling _via_ ‘sample’ takes place from ‘1:x’.  _Note_
 that this convenience feature may lead to undesired behaviour when
 ‘x’ is of varying length in calls such as ‘sample(x)’.  See the
 examples.

But I didn’t see a way to disable this feature. Is there a workaround or a way to stop it from treating objects of length one as numeric?

  • 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-25T21:41:24+00:00Added an answer on May 25, 2026 at 9:41 pm

    The sample documentation recommends this:

    resample <- function(x, ...) x[sample.int(length(x), ...)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a list of dates that is drawn from a MySQL database. That
I have a list of dates that a machine has worked on, but it
I have created a list view that displays the names and dates of items
I have a long list of files that all end in a date in
I have a list of dates stored in MySQL using PHP. These were stored
I have a long list of dates that i want to parse, they are
I have a list of Dates ( or DateMidnight from joda time) i rappresent
I have an ordered (i.e. sorted) list that contains dates sorted (as datetime objects)
Have a list of dates in excel in the format (this comes originally from
I have a list of households, and the dates that they moved into 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.