On 05/06/2019 4:34 a.m., le Gleut, Ronan wrote:
Dear R-help mailing list,
First of all, many many thanks for your great work on the R project!
I have a very small issue regarding the sample function. Depending if we
specify values for the prob argument, we don't get the same result fo
Dear R-help mailing list,
First of all, many many thanks for your great work on the R project!
I have a very small issue regarding the sample function. Depending if we
specify values for the prob argument, we don't get the same result for a
random sampling with replacement and with equal pr
On Sun, Feb 12, 2012 at 01:57:18PM -0500, SUPAKORN LAOHAPITAKVORN wrote:
> This is what I got:
>
> > sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_
Supakorn,
Try:
rm(sample)
#then
sample(x)
Etienne
2012/2/12 SUPAKORN LAOHAPITAKVORN
> This is what I got:
>
> > sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.
This is what I got:
> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
Hi,
The following is what I get:
> x =1:12
> x
[1] 1 2 3 4 5 6 7 8 9 10 11 12
> sample(x)
[1] 9 6 12 5 3 4 1 11 8 7 10 2
> sample(x, size = 2)
[1] 9 4
What's the output of sessionInfo() and ls() ? Perhaps you have a
different "sample" function in your workspace?
HTH,
Jorge
sessionInfo()?
Can you replicate this behavior in a R --vanilla session? This seems
very odd and I presume you've overwritten sample() somewhere in your
workspace.
Michael
On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN
wrote:
> Hi,
> Can anyone help me with the sample () in R?
>
> If
Hi,
Can anyone help me with the sample () in R?
If I sample from x, I should get one integer. Can anyone tell me what's
wrong here?
> x =1:12
> sample(x)
[1] 6.5
And, I cannot get the sample with size = 2
> sample(x, size = 2)
Error in sample(x, size = 2) : unused argument(s) (size = 2)
> sample
Well, you can have exactly 70:30%, i.e. 70% 1s and 30% 0s, but
in random order. For example:
Popn <- c(rep(1,70),rep(0,30))
Samp <- sample(Pop)
(see '?sample' for this usage -- the result of sample(x) is a
random permutation of the elements of x).
In probabilistic terms, this is a "condition
On 05/07/2011 2:25 PM, Joshua Wiley wrote:
Hi Ana,
Look at the documentation for ?sample, specifically, the "prob"
argument. In your case this should work:
sample(c(0,1), 100, replace = TRUE, prob = c(.3, .7))
note that you may not have *exactly* 70% 1 and 30%, in any given sample.
And if y
Hi Ana,
Look at the documentation for ?sample, specifically, the "prob"
argument. In your case this should work:
sample(c(0,1), 100, replace = TRUE, prob = c(.3, .7))
note that you may not have *exactly* 70% 1 and 30%, in any given sample.
HTH,
Josh
On Tue, Jul 5, 2011 at 11:21 AM, Ana Kolar
Hi there,
I guess this is an easy one, but still:
I would like to randomly sample 0s and 1s but in a way that I end up having for
example 70% of 1s and the rest of 0s and not 50:50 as this function
does: sample(c(0,1), 100, replace = TRUE)
Any recommendations?
Many thanks!
Ana
[[al
On 2011-02-19 10:32, Hongwei Dong wrote:
Hi, R users,
I'm wondering if there a way in R I can select cases based on a probability
vector. if a case is selected, that case is marked as 1, otherwise, 0.
For example:
x<-12:18
y<-1:7
sample(x,2,replace=FALSE,y)
I got:
[1] 15 17
What I want to s
Hi, R users,
I'm wondering if there a way in R I can select cases based on a probability
vector. if a case is selected, that case is marked as 1, otherwise, 0.
For example:
x<-12:18
y<-1:7
sample(x,2,replace=FALSE,y)
I got:
[1] 15 17
What I want to see is:
[1] 0 0 0 1 0 1 0
Thanks.
Gary
What is dataset?
What is this supposed to be doing?
newsample<-dataset[sample(m,replace=T),]
--- On Thu, 7/16/09, MarcioRibeiro wrote:
> From: MarcioRibeiro
> Subject: [R] Sample Function
> To: r-help@r-project.org
> Received: Thursday, July 16, 2009, 11:55 AM
>
> Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of MarcioRibeiro
> Sent: Thursday, July 16, 2009 8:56 AM
> To: r-help@r-project.org
> Subject: [R] Sample Function
>
>
> Hi listers,
> Supp
Hi listers,
Suppose I have a dataset with n=10 observations and I want to sample with
replacement.
My new sample is of size m=9.
So, I am using the following code...
newsample<-dataset[sample(m,replace=T),]
The problem is that generates the new sample and the last observation of my
data set is nev
Hi listers,
I am
--
View this message in context:
http://www.nabble.com/Sample-Function-tp24519071p24519071.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-hel
Hi,
I use sample function in a for loop to get a new random indexing but I don't
know why, I get the same indexes in different iterations of for.
I have a script that uses for loop calling crossval function (the same
definition as crossval in bootstrap package) defined in another script. Both
s
19 matches
Mail list logo