[R] Conditional sampling

2011-02-10 Thread Hosack, Michael
R experts, I need to sample two rows without replacement from the following data frame such that neither row contains the same 'DOW'. For example, I cannot select both a Monday morning and a Monday afternoon. I am using STRATA_NUM as an index to randomly select rows from, since this

Re: [R] Conditional sampling

2011-02-10 Thread Duncan Murdoch
On 10/02/2011 11:02 AM, Hosack, Michael wrote: R experts, I need to sample two rows without replacement from the following data frame such that neither row contains the same 'DOW'. For example, I cannot select both a Monday morning and a Monday afternoon. I am using STRATA_NUM as an index to

Re: [R] Conditional sampling?

2010-02-09 Thread Olga Lyashevska
Hello all, Here is my solution, in case someone else needs it. I have a dataframe consisting of two columns. col1-factor(c(a,a,b,b,c,c)) col2-factor(c(a,b,c,d,e,f)) somedf-data.frame(col1,col2) somedf col1 col2 1 a d 2 a e 3 b f 4 b g 5 c

[R] Conditional sampling?

2010-02-04 Thread Olga Lyashevska
Hello, I have a dataframe consisting of two columns. col1-factor(c(a,a,b,b,c,c)) col2-factor(c(a,b,c,d,e,f)) somedf-data.frame(col1,col2) somedf col1 col2 1 a d 2 a e 3 b f 4 b g 5 c h 6 c i sample(col1,2,replace=T) [1] b c

Re: [R] Conditional sampling?

2010-02-04 Thread ONKELINX, Thierry
-Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Olga Lyashevska Verzonden: donderdag 4 februari 2010 14:05 Aan: r-help@r-project.org Onderwerp: [R] Conditional sampling? Hello, I have a dataframe consisting of two columns. col1-factor

Re: [R] Conditional sampling?

2010-02-04 Thread Olga Lyashevska
Thanks Thierry! On 04.02.2010, at 13:22, ONKELINX, Thierry wrote: selection - subset(somedf, col1 != a) sample(selection$col2, 2, replace = TRUE) I simplified it, but in fact it is not only 'a' to be eliminated, but thousands of rows. Can I use: col1sample-sample(col1,2,replace=T)

[R] Conditional Sampling

2010-01-12 Thread ehcpieterse
Hi, I am hoping someone can help me with a sampling question. I am using the following function to sample 10 unique observations: x - sample(1:100, 10, replace=F) Given the first 10 observations, I need to sample another 5 unique observations from the remainder. I essentially want to do a Monte

Re: [R] Conditional Sampling

2010-01-12 Thread Ted Harding
On 12-Jan-10 12:58:13, ehcpieterse wrote: Hi, I am hoping someone can help me with a sampling question. I am using the following function to sample 10 unique observations: x - sample(1:100, 10, replace=F) Given the first 10 observations, I need to sample another 5 unique observations

Re: [R] Conditional Sampling

2010-01-12 Thread ehcpieterse
Thanks Ted, your solution does make perfect sense. The only question I still have is that I would like to sample the remaining 5 observations after I have randomly selected the first 10. Given the initial 10, I would like to sample the following 5 say 1,000 times to get a simulated conditional

Re: [R] Conditional Sampling

2010-01-12 Thread Magnus Torfason
Would the following work, or is there a reason why it would not? risk.set - 1:100 first.10 - sample(risk.set, 10) remainder - setdiff(risk.set, first.10) for ( i in 1:1000 ) { next.5 - sample(remainder, 5) do.something.with(next.5) } Best, Magnus On 1/12/2010 9:00 AM,

Re: [R] Conditional Sampling

2010-01-12 Thread Ted Harding
On 12-Jan-10 14:00:24, ehcpieterse wrote: Thanks Ted, your solution does make perfect sense. The only question I still have is that I would like to sample the remaining 5 observations after I have randomly selected the first 10. Given the initial 10, I would like to sample the following 5

Re: [R] Conditional Sampling

2010-01-12 Thread ehcpieterse
Thanks Ted, it's exactly what I'm after. Thanks for the help. -- View this message in context: http://n4.nabble.com/Conditional-Sampling-tp1012072p1012180.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

Re: [R] Conditional Sampling

2010-01-12 Thread Greg Snow
-help-boun...@r- project.org] On Behalf Of Ted Harding Sent: Tuesday, January 12, 2010 7:34 AM To: r-help@r-project.org Cc: ehcpieterse Subject: Re: [R] Conditional Sampling On 12-Jan-10 14:00:24, ehcpieterse wrote: Thanks Ted, your solution does make perfect sense. The only question I