Re: [R] Drawing a sample based on certain condition

2025-04-14 Thread Ebert,Timothy Aaron
1) select only denied individuals from the original data. This is S. 2) There is a fixed sample size of exactly t 3) There is a fixed target sum T such that sum(t values from S) = T You can reduce the problem. All large values where the max(S) + (t-1 smallest values) > T can be eliminated from S

Re: [R] Drawing a sample based on certain condition

2025-04-14 Thread Bert Gunter
Just a comment: You wish to draw subsets of size n with or without replacement -- and I suspect without replacement is simpler than with -- from a set of positive integers that sum to a fixed value T. This sounds related to the so-called subset sum problem in computational complexity theory: Given

Re: [R] Drawing a sample based on certain condition

2025-04-14 Thread Rui Barradas
Às 12:26 de 14/04/2025, Brian Smith escreveu: Hi, For my analytical work, I need to draw a sample of certain sample size from a denied population, where population members are marked by non-negative integers, such that sum of sample members if fixed. For example, Population = 0:100 Sample_size

[R] Drawing a sample based on certain condition

2025-04-14 Thread Brian Smith
Hi, For my analytical work, I need to draw a sample of certain sample size from a denied population, where population members are marked by non-negative integers, such that sum of sample members if fixed. For example, Population = 0:100 Sample_size = 10 Sample_Sum = 20 Under this setup if my sam

Re: [R] Drawing a sample based on certain condition

2025-04-14 Thread Duncan Murdoch
On 2025-04-14 7:26 a.m., Brian Smith wrote: Hi, For my analytical work, I need to draw a sample of certain sample size from a denied population, where population members are marked by non-negative integers, such that sum of sample members if fixed. For example, Population = 0:100 Sample_size =

Re: [R] Drawing a sample based on certain condition

2025-04-14 Thread Ebert,Timothy Aaron
1) extract relevant observations to a new data frame. Either of these two commands works. filter(df, age > 24) df[df$age > 24, ] 2) sample the new data frame df[sample(nrow(df), 10, replace = TRUE), ] change TRUE to FALSE if you do not want replacement. Tim -Original Message- From: R-hel