On Sep 25, 2015, at 12:54 PM, Lorenzo Isella wrote:
> Apologies for not letting this thread rest in peace.
> The small script
>
> #
> set.seed(1234)
>
> x <- rnorm(20)
> y <- rnorm(20)
>
>
> goodcls <- apply(mtxcomb , 2, function(idx) al
Apologies for not letting this thread rest in peace.
The small script
#
set.seed(1234)
x <- rnorm(20)
y <- rnorm(20)
goodcls <- apply(mtxcomb , 2, function(idx) all( dist( cbind( x[idx],
y[idx]) ) > 0.9))
mycomb <- mtxcomb [ , goodcls]
#
lt;-(dist(mm))
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Thursday, September 24, 2015 6:30 PM
To: Lorenzo Isella
Cc: David L Carlson; r-help@r-project.org
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Thursday, September 24, 2015 6:30 PM
To: Lorenzo Isella
Cc: David L Carlson; r-help@r-project.org
Subject: Re: [R] Sampling the Distance Matrix
On Sep 24, 2015, at 1:54 PM, Lorenzo Isella wrote:
> On
On Sep 24, 2015, at 1:54 PM, Lorenzo Isella wrote:
> On Thu, Sep 24, 2015 at 01:30:02PM -0700, David Winsemius wrote:
>>
>> On Sep 24, 2015, at 12:36 PM, Lorenzo Isella wrote:
>>
>>> Hi,
>>> And thanks for your reply.
>>> Essentially, your script gets the job done.
>>> For instance, if I run
>>
On Thu, Sep 24, 2015 at 01:30:02PM -0700, David Winsemius wrote:
On Sep 24, 2015, at 12:36 PM, Lorenzo Isella wrote:
Hi,
And thanks for your reply.
Essentially, your script gets the job done.
For instance, if I run
mm <- cbind(5/(1:5), -2*sqrt(1:5))
dst <- dist(mm)
dst2 <- as.matrix(dst)
diag
>>13 18 19
>> 13 NA 2.272407 3.606054
>> 18 2.272407 NA 1.578150
>> 19 3.606054 1.578150 NA
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A&M Univers
p-boun...@r-project.org] On Behalf Of William Dunlap
Sent: Wednesday, September 23, 2015 3:23 PM
To: Lorenzo Isella
Cc: r-help@r-project.org
Subject: Re: [R] Sampling the Distance Matrix
mm <- cbind(1/(1:5), sqrt(1:5))
d <- dist(mm)
d
1 2 3 4
2 0.6492864
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap
Sent: Wednesday, September 23, 2015 3:23 PM
To: Lorenzo Isella
Cc: r-help@r-project.org
Subject: Re: [R] Sampling the Distance Matrix
> mm <- cbind(1/(1:5), sqrt(1:5))
> d <- dist
> mm <- cbind(1/(1:5), sqrt(1:5))
> d <- dist(mm)
> d
1 2 3 4
2 0.6492864
3 0.9901226 0.3588848
4 1.250 0.6369033 0.2806086
5 1.4723668 0.8748970 0.5213550 0.2413050
> which(as.matrix(d)>0.9, arr.ind=TRUE)
row col
3 3 1
4 4 1
5 5 1
1 1 3
1 1
If df is the data.frame with values and you want nn samples, then this
is a slightly different approach:
# example data.frame:
df = data.frame(a1 = sample(1:20,50, replace = TRUE),
a2 = sample(seq(0.1,10,length.out =
30),50, replace = TRUE),
Hi Jean,
Thanks!
Daniel,
Yes, you are absolutely right. I want sampled vectors to be as different
as possible.
I added a little more to the earlier data set.
x1 x2 x3
[1,] 1 3.7 2.1
[2,] 2 3.7 5.3
[3,] 3 3.7 6.2
[4,] 4 3.7 8.9
[5,] 5 3.7 4.1
[6,] 1 2.9 2.1
[7,] 2 2
On 6/22/2015 9:42 AM, C W wrote:
Hello R list,
I am have question about sampling unique coordinate values.
Here's how my data looks like
dat <- cbind(x1 = rep(1:5, 3), x2 = rep(c(3.7, 2.9, 5.2), each=5))
dat
x1 x2
[1,] 1 3.7
[2,] 2 3.7
[3,] 3 3.7
[4,] 4 3.7
[5,] 5 3.7
Mike,
There may be a more efficient way to do this, but this works on your
example.
# mix up the order of the rows
mix <- dat[order(runif(dim(dat)[1])), ]
# get rid of duplicate x1s and x2s
sub <- mix[!duplicated(mix[, "x1"]) & !duplicated(mix[, "x2"]), ]
sub
Jean
On Mon, Jun 22, 2015 at 11:42
On 3/29/2015 11:10 PM, Partha Sinha wrote:
I have 1000 data points. i want to take 30 samples and find mean. I
also want to repeat this process 100 times. How to go about it?
Regards
Parth
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and mor
That worked great, thanks so much David!
On Wed, Mar 4, 2015 at 8:23 AM, David L Carlson wrote:
> I'm not sure I understand, but I think you have a large data frame with
> records and you want to construct a sample of that data frame that includes
> no more than 3 records for each IDbyYear combi
Since you indicated there are six more columns in the data.frame, getSample
modified below to take care of it.
> getSample
function(x)
{
sites <- unique(x$SiteID)
years <- unique(x$Year)
result <- data.frame()
x$ID <- seq(1,nrow(x))
for (i in 1:length(sites))
{
for (j in 1:length(y
Here is an implementation with function named getSample. Some modification to
the data was made so that it can be read as a table.
> fitting.set
IDbyYear SiteID Year
1 42.24 A-Airport 2006
2 42.24 A-Airport 2006
3 42.24 A-Airport 2006
4 42.
I'm not sure I understand, but I think you have a large data frame with records
and you want to construct a sample of that data frame that includes no more
than 3 records for each IDbyYear combination? You say there are 5589 unique
combinations and your code uses a data frame called fitting_set.
> myProbs[ which(ntype == 0)] <- 0.75/7 # Divide so the sum will be 1.0
> myProbs[ which(ntype == 1)] <- 0.25/3
Here of course you need to divide by number of 0s and 1s, 7 and 3
were was just an example.
__
R-help@r-project.org mailing list
https://sta
If I understood correctly, you need weighted sampling. Try 'prob'
argument from 'sample'. For your example:
n <- 10
ntype <- rbinom(n, 1, 0.5)
myProbs <- rep(1/10, 10) # equally likely
myProbs[ which(ntype == 0)] <- 0.75/7 # Divide so the sum will be 1.0
myProbs[ which(ntype == 1)] <- 0.25/3
samp
Hi,
You may try:
dat1 <- structure(list(SubID = 1:8, CSE1 = c(6L, 6L, 5L, 5L, 5L, 5L,
3L, 3L), CSE2 = c(5L, 4L, 5L, 4L, 6L, 4L, 6L, 6L), CSE3 = c(6L,
7L, 5L, 3L, 7L, 3L, 6L, 6L), CSE4 = c(2L, 2L, 5L, 4L, 5L, 6L,
3L, 3L), WSE1 = c(6L, 6L, 5L, 4L, 6L, 4L, 6L, 6L), WSE2 = c(2L,
6L, 5L, 4L, 4L, 3L
Arguably you are looking in the wrong place (there's a special mixed-models
mailing list for R), but I can answer the question.
No.
At least, there's nothing in lme4, and I haven't done anything (since I
want a more general solution than Stata and MLWiN implement) and I'd be
surprised if someone
Perhaps you should read the help file for rnorm more carefully.
?rnorm
Keep in mind that the normal probability distribution is a density function, so
the smaller the standard deviation is, the greater the magnitude of the density
function is.
--
Hi Lorenzo,
This has the feel of a homework problem, but I will suggest to you
that this is "sampling without replacement" and there exist easy
mathematical formulas (no need to resort to R) to calculate your
desired probability.
Michael
On Sat, Dec 8, 2012 at 11:54 AM, Lorenzo Isella
wrote:
>
Thank you very much, Thomas!
As I need to estimate the variance components, I will most probably have to
switch from R to HLM or Mplus to apply different weights to different
levels.
Although I prefer R in general.
--
View this message in context:
http://r.789695.n4.nabble.com/sampling-weights-
Thank you very much, Rui!
But I am afraid that I won't be able to use this function for multilevel
analysis, as unfortunately I don't see how exactly I will combine it with
functions in the R packages for multilevel analysis .
--
View this message in context:
http://r.789695.n4.nabble.com/samplin
On Mon, Jun 11, 2012 at 7:00 AM, Tamara wrote:
> Dear all,
>
> I am struggling with a problem which I have been reading on the forums about
> and it did not seem to me that there is a precise answer to my question.
> However, I still hope there is one.
>
> I am working with http://timss.bc.edu/ P
Hello,
The link you've posted is to a page that does NOT have a dataset, it has
links to other pages. The proper way of posting a data example would be
# paste the output of this in a post
dput(head(yourdata, 20)) # or 30
Now, if I understand your question, function sample() does have a
we
## recreating your data
mydata<-list(matrix(1:9, nrow=3, byrow=T),
matrix(10:15, nrow=2, byrow=T),
matrix(16:30, nrow=5, byrow=T))
## get the shortest matrix in your list
n <- min(unlist(lapply(mydata, nrow)))
## subset the list into random samples of length n
??
Something like:
lapply(mydata, function(x){
nr <- nrow(x)
x[sample(seq_len(nr),nr,rep=TRUE),]
})
maybe. The idea is to use the sampled rows as your row index.
-- Bert
On Mon, Apr 2, 2012 at 11:24 AM, Bcampbell99 wrote:
> Hi:
>
> I'm sure this seems like a rudimentary question, but I am n
Please use dput() to give a reproducible example: I can make this work
on a data frame quite easily --
x <- data.frame(1:10, letters[1:10], rnorm(10))
str(x)
print(x)
x[sample(nrow(x), 5), ]
So it's not a problem with something being a data frame or having factors.
Michael
On Thu, Mar 8, 2012 a
Thanks, but it doesn't work either, it gives me the same message error.
It works just if my first sample is taken in this way:
mysample <- sample(1:nrow(MeanA), 20, replace=FALSE)
However, in this way it sample just the number of rows:
[1] 71 24 12 36 2 39 69 62 43 38 9 44 13 54 50 63 67 66 3
>
> Hi, thank you but it does work for vectors and matrix but not
dataframes, it
> gives me this message error:
>
> MeanA <- read.csv("MeanAmf.csv",header=T)
> mysample <- MeanA[sample(1:nrow(MeanA), 20, replace=FALSE),]
Well, maybe slight correction
mysample <- sample(1:nrow(MeanA), 20, repla
Hi
I have only faint idea what was you problem as there is no context in you
message but maybe
remainder<-MeanA[-mysample, ]
could work.
Regards
Petr
>
> Hi, thank you but it does work for vectors and matrix but not
dataframes, it
> gives me this message error:
>
> MeanA <- read.csv("MeanA
Hi sarah, it is not clear to me how to do that, can you show me please?
Imagine I have a situation like this:
MeanA <- read.csv("MeanAmf.csv",header=T)
mysample <- MeanA[sample(1:nrow(MeanA), 20, replace=FALSE),]
Then?
--
View this message in context:
http://r.789695.n4.nabble.com/Sampling-pr
Hi, thank you but it does work for vectors and matrix but not dataframes, it
gives me this message error:
MeanA <- read.csv("MeanAmf.csv",header=T)
mysample <- MeanA[sample(1:nrow(MeanA), 20, replace=FALSE),]
remainder<-MeanA[-mysample]
Error in `[.default`(MeanA, -mysample) : invalid subscript ty
On Mar 7, 2012, at 11:41 AM, Oritteropus wrote:
Hi,
I need to sample randomly my dataset for 1000 times. The sample need
to be
the 80%. I know how to do that, my problem is that not only I need
the 80%,
but I also need the corresponding 20% each time. Is there any way to
do
that?
Alterna
On Wed, Mar 07, 2012 at 08:41:35AM -0800, Oritteropus wrote:
> Hi,
> I need to sample randomly my dataset for 1000 times. The sample need to be
> the 80%. I know how to do that, my problem is that not only I need the 80%,
> but I also need the corresponding 20% each time. Is there any way to do
> t
You could make a vector containing the number of TRUE values that
makes up 80% of your data, and the number of FALSE values that makes
up 20% of your data. Use sample() to reorder it, then use it to divide
your dataset.
If you had provided a reproducible example, I could write you code.
Sarah
On
On Wed, Jan 25, 2012 at 04:00:27AM -0800, Eliano wrote:
> Hi People,
>
> Does anyone have a good solution for this problem:
>
> a database called DB.
>
>
> index <- sample(1:nrow(DB), size=0.2*nrow(BD))
> test <- DB[index,]
> train <- DB[-index,]
>
> One of the variables in this database
Hi People,
Does anyone have a good solution for this problem:
a database called DB.
index <- sample(1:nrow(DB), size=0.2*nrow(BD))
test <- DB[index,]
train <- DB[-index,]
One of the variables in this database contais a target variable with two
values 0 and 1.
Imagine now that i want to
On Jan 24, 2012, at 20:41 , Thomas Lumley wrote:
> It's not meant for sampling weights. It's meant for precision
> weights. How best to include sampling weights in mixed models is a
> research problem at the moment, but you can rely on getting the wrong
> answer if you just use the weights= arg
On Tue, Jan 24, 2012 at 6:19 PM, Mohd masood wrote:
>
> Dear All
> I am trying to include sampling weights in multilavel regression analysis
> using packege lme4 using following codes
>
> print(fm1 <- lmer(DC~sex+age+smoker+alcohol+fruits(1|setting),
> dataset,REML = FALSE), corr = FALSE)
> prin
1) Use dput() to submit data.
2) Would this work? (It requires your data are evenly spaced, but I
think that's it) d[seq(1, nrow(d), by = 3), ]
Michael
On Wed, Dec 14, 2011 at 7:17 AM, abcdef ghijk wrote:
> Good Morning ,
>
> I want to sample the following time series for every third hour. For
Dan
Nordlund, Dan (DSHS/RDA) wrote:
>
>> -Original Message-
>> From: r-help-bounces@ [mailto:r-help-bounces@r-
>> project.org] On Behalf Of SarahJoyes
>> Sent: Tuesday, November 08, 2011 5:57 AM
>> To: r-help@
>> Subject: Re: [R] Sampling with c
-Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> project.org] On Behalf Of SarahJoyes
>> Sent: Tuesday, November 08, 2011 5:57 AM
>> To: r-help@r-project.org
>> Subject: Re: [R] Sampling with conditions
>>
>> Tha
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of SarahJoyes
> Sent: Tuesday, November 08, 2011 5:57 AM
> To: r-help@r-project.org
> Subject: Re: [R] Sampling with conditions
>
> That is exactly what I
That is exactly what I want, and it's so simple!
Thanks so much!
--
View this message in context:
http://r.789695.n4.nabble.com/Sampling-with-conditions-tp4014036p4016050.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-projec
Sorry about being confusing, I have so many loops in loops and ifelses that I
get mixed up sometimes, it was just a typo, it was supposed to be "for(i in
1:5)" Sorry,
Thanks for you help!
SJ
--
View this message in context:
http://r.789695.n4.nabble.com/Sampling-with-conditions-tp4014036p40
[Yet another correction -- this one is important.
I start from scratch this time]
On 07-Nov-11 22:22:54, SarahJoyes wrote:
> Hey everyone,
> I am at best, an amateur user of R, but I am stuck on how
> to set-up the following situation.
> I am trying to select a random sample of numbers from 0 t
[Correction below (I was writing too late at night ... ]
On 08-Nov-11 00:25:57, Ted Harding wrote:
> On 07-Nov-11 22:22:54, SarahJoyes wrote:
>> Hey everyone,
>> I am at best, an amateur user of R, but I am stuck on how
>> to set-up the following situation.
>> I am trying to select a random samp
On 07-Nov-11 22:22:54, SarahJoyes wrote:
> Hey everyone,
> I am at best, an amateur user of R, but I am stuck on how
> to set-up the following situation.
> I am trying to select a random sample of numbers from 0 to 10
> and insert them into the first column of a matrix (which will
> used later in
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of SarahJoyes
> Sent: Monday, November 07, 2011 2:23 PM
> To: r-help@r-project.org
> Subject: [R] Sampling with conditions
>
> Hey everyone,
> I am at best, an amateur user of R, but
Not sure this is valid that you can have 9 random samples out of 10,
but the last one has to be fixed to meet the restraint, sum=10.
Weidong
On Mon, Nov 7, 2011 at 5:22 PM, SarahJoyes wrote:
> Hey everyone,
> I am at best, an amateur user of R, but I am stuck on how to set-up the
> following sit
Well, for 0.828324 < x[2] < Inf the probablility is roughly 0 hence not
easy to draw random numbers out there
Uwe Ligges
How is this probability roughly 0?
--
View this message in context:
http://r.789695.n4.nabble.com/sampling-from-the-multivariate-truncated-normal-tp3626438p3647039.ht
On 26.06.2011 21:26, statfan wrote:
I am trying generate a sample for a truncated multivariate normal
distribution via the rtmvnorm function in the {tmvtnorm} package.
Why does the following produce NaNs?
rtmvnorm(1, mean = rep(0, 2), matrix(c(0.06906084, -0.07463565, -0.07463565,
0.0807808
On Thu, Mar 31, 2011 at 4:01 AM, Simon Kiss wrote:
> Dear colleagues,
> I'm working with the 2008 Canada Election Studies
> (http://www.queensu.ca/cora/_files/_CES/CES2008.sav.zip), trying to construct
> a weighted national sample using the survey package.
> Three weights are included in the nat
Hi:
A couple more approaches to consider:
# Utility function to extract two rows from a data frame
# Meant to be applied to each data subset
sampler <- function(d) if(nrow(d) > 2) d[sample(1:nrow(d), 2, replace =
FALSE), ] else d
library(plyr)
> ddply(x, 'id', sampler)
id v1 V2
1 1 2 13
2 1
On Feb 17, 2011, at 1:33 PM, andrija djurovic wrote:
This is, maybe, not the best solution but I hope it will help you:
x<-data.frame(id=c(1,1,1,2,2,2,2,3,3,3,4,4), v1=c(1:12), V2=c(12:23))
do.call("rbind",by(x,x$id,function(x) x[c(sample(nrow(x),2)),]))
Andrija
Another way (and note that
This is, maybe, not the best solution but I hope it will help you:
x<-data.frame(id=c(1,1,1,2,2,2,2,3,3,3,4,4), v1=c(1:12), V2=c(12:23))
do.call("rbind",by(x,x$id,function(x) x[c(sample(nrow(x),2)),]))
Andrija
On Thu, Feb 17, 2011 at 6:39 PM, yf wrote:
>
> But i need for each id have two data
But i need for each id have two data.
Like...
> x
id v1 V2
1 1 1 12
2 1 2 13
4 2 4 15
5 2 5 16
8 3 8 19
9 3 9 20
11 4 11 22
12 4 12 23
So should write sample( if sample id >2 ,2). I don't know how to write (if
sample id >2). Thanks.
--
View this message in context:
On Feb 16, 2011, at 11:35 PM, yf wrote:
I want to sample from the ID. For each ID, i want to have 2 set of
data. I
try the sample() function but it didn't work.
You don't say _how_ you used the sample function. You should show what
code you used when stating the _something_ "doesn't wor
Hi ,
what about split function ?
?split divided x into 2 data.frame
a<-split(x,1:2)
a[[1]] first data frame
a[[2]] second data frame
regrads
M
Le 17/02/11 05:35, yf a écrit :
> I want to sample from the ID. For each ID, i want to have 2 set of data. I
> try the sample() function but it did
Generating new data from a kernel density estimate is equivalent to choosing a
point from your data at random, then generating a point from your kernel
centered at the chosen point.
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111
yes, the data.frame is exactly the same as the one I posted earlier.
I was trying to see if the loop function works. And I got that message. here
below is the syntax I was trying to run, followed by the error message at
the end:
> sampleX<-function(X,nGrp1,nsamples){if(nGrp1>=4)stop("can't sampl
On 16 November 2010 16:10, wangwallace wrote:
>
> Michael, I really appreciate your help.
>
> but I got the following error message when I wan trying to run the function
> written by you:
>
> Error in out[i, ] <- apply(help[, c(grp1 + 1, grp2 + 5)], 2, sample, 1) :
> number of items to replace is
Michael, I really appreciate your help.
but I got the following error message when I wan trying to run the function
written by you:
Error in out[i, ] <- apply(help[, c(grp1 + 1, grp2 + 5)], 2, sample, 1) :
number of items to replace is not a multiple of replacement length
I am not quite sure
Hello,
Is this what you want ?
sampleX <- function(X, nGrp1, nsamples)
# X is matrix or data.frame with cols for two groups of variables
# with grp1 in cols 2:5 and grp2 in cols 6:9
#
# nGrp1 <- number of variables to sample from group 1
#
# nsamples <- number of rows in output matrix
if (nGrp
Hi Solafah,
You are right that two commands are equivalent when p= pnorm(a). You can
check the results by following codes.
n <- 5
a <- -1
set.seed(123456)
qnorm(runif(n,0,pnorm(a)))
p <- pnorm(a)
set.seed(123456)
qnorm(p*runif(n))
Anyway, the elements of the lower tail are not chosen equally by
If poproh.3 was your dataset as a data.frame (an object with row and
column dimensions), you need a comma following the row selection
(sample(...)) to indicate that you want to select those rows and all
columns:
newsample <-poprho.3[sample(1:1,100),] # note the last comma in the brackets
Gene
We'll probably need much more info, but this should get you started:
nameOfDataSet[sample(1:1, 100),]
You can replace the 1 with dim(nameOfDataSet)[1] to make it more dynamic.
Jeff.
On Tue, Oct 5, 2010 at 3:07 AM, Jumlong Vongprasert
wrote:
> Dear all.
> I have data with 2 variable x,y
On 03/10/2010 6:38 PM, solafah bh wrote:
Hello
If i want to resampl from the tails of normal distribution , are these commans
equivelant??
upper tail:qnorm(runif(n,pnorm(b),1)) if b is an upper tail boundary
or
upper tail:qnorm((1-p)+p(runif(n)) if p is the probability of each interval
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of solafah bh
> Sent: Sunday, October 03, 2010 3:39 PM
> To: R help mailing list
> Subject: [R] sampling from normal distribution
>
> Hello
> If i want to resampl from the tails of
Hi:
Try this:
do.call(rbind, lapply(split(h, h$file), function(x) x[sample(1:nrow(x), 1),
]))
My test returns
file time_pred distance_1 distance_2
12.03.08_ins_odo_01 12.03.08_ins_odo_01 210 19.003 18.023
12.03.08_ins_odo_02 12.03.08_ins_odo_02
Hi, take the following example and proceed accordingly.
Name=c("Miller","Miller","Miller","Miller","Smith","Smith","Smith","Smith")
X=rnorm(8)
Year=rep(2000:2003,2)
d=data.frame(Name,X,Year)
#Row indices
rows=1:dim(d)[1]
#Which Name occupies which rows?
#"Name" would be your "file"
w=function(
On 06/17/2010 03:27 AM, Somnath Somnath wrote:
Thanks for all those reply. Is there any general rule to determine how many
samples I would get from a population of size "n", I draw a sample of size
"m" ("m" may be greater than "n") if sample is drawn with replacement?
Hi Somnath,
If you mean "h
Somnath Somnath [Wed, Jun 16, 2010 at 07:27:32PM
CEST]:
> Thanks for all those reply. Is there any general rule to determine how many
> samples I would get from a population of size "n", I draw a sample of size
> "m" ("m" may be greater than "n") if sample is drawn with replacement?
m^n
--
Joh
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Somnath Somnath
> Sent: Wednesday, June 16, 2010 10:28 AM
> To: r-help@r-project.org
> Subject: Re: [R] Sampling with replacement
>
> Thanks for all t
Thanks for all those reply. Is there any general rule to determine how many
samples I would get from a population of size "n", I draw a sample of size
"m" ("m" may be greater than "n") if sample is drawn with replacement?
Thanks,
2010/6/16 Jorge Ivan Velez
> Hi Rafael,
>
> You might try:
>
> >
How about
library(TeachingSampling)
SupportWR(20,4)
Tom
--
View this message in context:
http://r.789695.n4.nabble.com/Sampling-with-replacement-tp2257450p2257644.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.or
Hi Rafael,
You might try:
> r <- expand.grid(rep(list(1:20), 4))
> dim(r)
[1] 16 4
HTH,
Jorge
2010/6/16 Rafael Björk <>
> If you for some reason want to be shown all the possible combinations, try
> expand.grid(1:20,1:20,1:20,1:20) (ugly code). Don't use this for sampling.
>
> hth Ra
On Jun 16, 2010, at 10:20 AM, Somnath Somnath wrote:
Dear all, good morning,
I have a population, let say members are tagged with some simple
number like
1,2,3,...20. I want to draw a sample with replacement of size 4
(say, can be
more than 20 also).
Already answered on the list.
Is t
If you for some reason want to be shown all the possible combinations, try
expand.grid(1:20,1:20,1:20,1:20) (ugly code). Don't use this for sampling.
hth Rafael
2010/6/16 Jorge Ivan Velez
> Try
>
> sample(20, 4, replace = TRUE)
>
> HTH,
> Jorge
>
>
> On Wed, Jun 16, 2010 at 10:20 AM, Somnath So
Try
sample(20, 4, replace = TRUE)
HTH,
Jorge
On Wed, Jun 16, 2010 at 10:20 AM, Somnath Somnath <> wrote:
> Dear all, good morning,
>
> I have a population, let say members are tagged with some simple number
> like
> 1,2,3,...20. I want to draw a sample with replacement of size 4 (say, can
> be
sample(1:20,4,replace=TRUE) should do it.
Jun
On Wed, Jun 16, 2010 at 9:20 AM, Somnath Somnath wrote:
> Dear all, good morning,
>
> I have a population, let say members are tagged with some simple number
> like
> 1,2,3,...20. I want to draw a sample with replacement of size 4 (say, can
> be
> mo
Intermountain Healthcare
greg.s...@imail.org
801.408.8111
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Haneef_An
> Sent: Monday, February 15, 2010 11:53 AM
> To: r-help@r-project.org
> Subject: Re: [R] Sampl
When I wrap those values in to a matrix will it be still independent ? ( non
zero correlation).
Can I do this for any multivariate distribution which has the univariate
form?
Thank you for the response.
Haneef
--
View this message in context:
http://n4.nabble.com/Sampling-from-Bivariate-Unif
The runif function generates random numbers from a uniform distribution, wrap
those values into a matrix and you have a multi dimensional uniform
distribution.
If you want more than this, give us more detail.
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg
On Tue, 19 Jan 2010, Christian Hennig wrote:
are there any R-packages for computations required in sampling theury (such
as confidence intervals under random, stratified, cluster sampling; I'd be
partoculary interested in confidence intervals for the population variance,
which is difficult eno
On 01/15/2010 01:49 AM, Bart Joosen wrote:
>
> One way could be to first select only the unique ID's, sample this and then
> select only the relevant records:
>
> strQuery = "SELECT ID from tblFoo;"
> IDs <- sqlQuery(channel, strQuery)
> sample.IDs <- sample(IDs,10)
> strQuery = paste("SELECT ID
One way could be to first select only the unique ID's, sample this and then
select only the relevant records:
strQuery = "SELECT ID from tblFoo;"
IDs <- sqlQuery(channel, strQuery)
sample.IDs <- sample(IDs,10)
strQuery = paste("SELECT ID from tblFoo WHRE ID IN(", sample.IDs, ");")
IDs <- sqlQuery
Here are some options that may help you out. First,
let's put the data in a format that can be cut-and-pasted
into R.
myData <- read.table(textConnection("var1 var2 var3
1 111
2 312
3 813
4 614
51015
6 221
7 422
8
ter
Cc: 'Marcio Resende'; r-help@r-project.org
Subject: Re: [R] Sampling procedure
If parsimony is needed, then define a 9-row matrix and send a
randomized indexed version of Example to it:
s<-matrix(NA, nrow=9, ncol=length(Example)/9)
s[,] <- Example[sample(Example, length(Example) )]
net]
Sent: Thursday, October 15, 2009 8:48 AM
To: Bert Gunter
Cc: 'Marcio Resende'; r-help@r-project.org
Subject: Re: [R] Sampling procedure
If parsimony is needed, then define a 9-row matrix and send a
randomized indexed version of Example to it:
s<-matrix(NA, nrow=9, nc
nal Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org
] On
Behalf Of David Winsemius
Sent: Thursday, October 15, 2009 7:55 AM
To: Marcio Resende
Cc: r-help@r-project.org
Subject: Re: [R] Sampling procedure
On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote:
I
, 2009 7:55 AM
To: Marcio Resende
Cc: r-help@r-project.org
Subject: Re: [R] Sampling procedure
On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote:
>
> I would like to divide a vector in 9 groups in a way that each
> number is
> present in only one group.
> In a vector of 783 I would li
On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote:
I would like to divide a vector in 9 groups in a way that each
number is
present in only one group.
In a vector of 783 I would like to divide in 9 different groups of 87
Example <- matrix(c(1:783),ncol = 1)
> Example <- matrix(c(1:783)
(assuming, as
stated above, that the total length of all the intervals is a small proportion
of the length of the "big interval").
--- On Mon, 20/7/09, Hadassa Brunschwig
wrote:
> From: Hadassa Brunschwig
> Subject: Re: [R] Sampling of non-overlapping intervals of variab
Thanks Chuck.
Ups, did not think of the problem in that way.
That did exactly what I needed. I have another complication to this problem:
I do not only have one vector of 1:1e^6 but several vectors of
different length, say 5.
Initially, my intervals are distributed over those 5 vectors and the
ra
1 - 100 of 143 matches
Mail list logo