[R] Sample selection problem
Jenny Barnes
jmb at mssl.ucl.ac.uk
Wed Oct 3 13:54:25 CEST 2007
Hi,
Can't you do something like:
x <- c(1,1,1,1,1,1,0,0,0,0)
sample(x, 30, T)
Best Wishes,
Jenny
>X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on hypatia.math.ethz.ch
>X-Spam-Level:
>X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED, DKIM_VERIFIED,
HTML_MESSAGE autolearn=no version=3.2.3
>X-YMail-OSG:
sIA8jEAVM1l7INcavAEUFuJk.tlFK1fXrul.GxIEMcxm_vue__YCqQXvo5CFerX5LVHjZDKx7.BqRTj0
zDdTOIevqWu2.u8JP9P2fJkBk9_vTPE.0fORnQ0Oxa9ekA--
>Date: Wed, 3 Oct 2007 12:51:14 +0100 (BST)
>From: stat stat <stat700004 at yahoo.co.in>
>To: r-help at stat.math.ethz.ch
>MIME-Version: 1.0
>X-Virus-Scanned: by amavisd-new at stat.math.ethz.ch
>Content-Disposition: inline
>Subject: [R] Sample selection problem
>X-BeenThere: r-help at r-project.org
>X-Mailman-Version: 2.1.9
>List-Id: "Main R Mailing List: Primary help" <r-help.r-project.org>
>List-Unsubscribe: <https://stat.ethz.ch/mailman/listinfo/r-help>,
<mailto:r-help-request at r-project.org?subject=unsubscribe>
>List-Archive: <https://stat.ethz.ch/pipermail/r-help>
>List-Post: <mailto:r-help at r-project.org>
>List-Help: <mailto:r-help-request at r-project.org?subject=help>
>List-Subscribe: <https://stat.ethz.ch/mailman/listinfo/r-help>,
<mailto:r-help-request at r-project.org?subject=subscribe>
>Content-Transfer-Encoding: 7bit
>X-MSSL-MailScanner-Information: Please contact the ISP for more information
>X-MSSL-MailScanner: No virus found
>X-MSSL-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.906, required 5,
BAYES_00 -4.90, FROM_ENDS_IN_NUMS 0.99)
>
>I want to get a sample of some arbitrary size from a population having only two
values 0 and 1 with replacement, but with different probability for selection.
For example 0 will be selected with probability 0.4 and 1 with 0.6. I could use
sample function i.e. sample(c(0,1), 30, T) to get this, however here, selection
of either 0 or 1 has equal probability here. I am looking for a function which
can do the same thing but with different probabilities.
>
>---------------------------------
> Meet people who discuss and share your passions. Join them now.
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jennifer Barnes
PhD student: long range drought prediction
Climate Extremes Group
Department of Space and Climate Physics
University College London
Holmbury St Mary
Dorking, Surrey, RH5 6NT
Tel: 01483 204149
Mob: 07916 139187
Web: http://climate.mssl.ucl.ac.uk
More information about the R-help
mailing list