[R] Random Sampling

2013-03-06 Thread Angelo Scozzarella Tiscali
When the population values are not distributed symmetrically about the mean, reporting the mean and standard deviation can give the reader an inaccurate impression of the distribution of values in the population. I'd like generating random samples with same mean and standard deviation, but not

Re: [R] random sampling matrix

2012-12-18 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of ??? > Sent: Tuesday, December 18, 2012 9:08 PM > To: r-help@r-project.org > Subject: [R] random sampling matrix > > Hello > > > > I have

[R] random sampling matrix

2012-12-18 Thread 김지현
Hello I have a one question about random sampling matrix I want to regeneration value of matrix For example, Matrix A : 1 2 3 11 12 13 21 22 23 . > sample= data.frame(a[sample(1:dim(a)[1]),sample(1:dim(a)[2])]) Then, Matrix sample : 21 23 22 11 13 12 1 3 2 But, I want

Re: [R] random sampling vector from any dsitribution

2012-12-18 Thread Michael Weylandt
On Dec 18, 2012, at 9:07 AM, Kairos2012 wrote: > Hi, > > help is very much appreciated. Thanks in advance!!! > > rgamma(...) > As far as I know with this function (code) one can randomly sample 100 > numbers simultanously. > > Question is: is it possible to sample 100 random numbers e.g. fro

[R] random sampling vector from any dsitribution

2012-12-18 Thread Kairos2012
Hi, help is very much appreciated. Thanks in advance!!! rgamma(...) As far as I know with this function (code) one can randomly sample 100 numbers simultanously. Question is: is it possible to sample 100 random numbers e.g. from 100 different gamma distributions using only one command line (or:

Re: [R] Random sampling many times and run through glm model

2012-11-13 Thread chuck.01
see: ?boot SASandRlearn wrote > I have a large dataset from which i need to take a random sample many > times ( say N=50) and run it through the same glm() - logistic regression > model everytime ( 50 times ) and capture the chi-square p-values ( Pr > > ChiSq ) of the variables for each run an

[R] Random sampling many times and run through glm model

2012-11-13 Thread SASandRlearn
I have a large dataset from which i need to take a random sample many times ( say N=50) and run it through the same glm() - logistic regression model everytime ( 50 times ) and capture the chi-square p-values ( Pr > ChiSq ) of the variables for each run and output average p-value of the variables

Re: [R] random sampling inside a dataset

2012-10-04 Thread Marianna Chimienti
; >>> > >>> Duncan Murdoch > >>> > >>> > >>> Thanks a again, > >>>> > >>>> > >>>> Gian > >>>> > >>>> On 13 September 2012 12:26, anna freni sterrantino < > annafr.

Re: [R] random sampling inside a dataset

2012-10-04 Thread Duncan Murdoch
no Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. -- *Da:* Gian Maria Niccolň Benucci *A:* r-help@r-project.org *Inviato:* Giovedě 13 Settembre 2012 10:42 *Oggetto:* [R] random sampling inside a dataset Hi all, I am wondering if do

Re: [R] random sampling inside a dataset

2012-10-04 Thread Rui Barradas
>>> Duncan Murdoch >>>> >>>> >>>> Thanks a again, >>>>> >>>>> Gian >>>>> >>>>> On 13 September 2012 12:26, anna freni sterrantino >>>> >>>>>> wrote: >&

Re: [R] random sampling inside a dataset

2012-10-04 Thread Gian Maria Niccolò Benucci
>>> Gian >>>> >>>> On 13 September 2012 12:26, anna freni sterrantino >>> >>>>> wrote: >>>>> >>>> >>>> Hello Gian, >>>> >>>>> sure sample function >>>>> will do it for y

Re: [R] random sampling inside a dataset

2012-09-13 Thread Duncan Murdoch
p@r-project.org *Inviato:* Giovedì 13 Settembre 2012 10:42 *Oggetto:* [R] random sampling inside a dataset Hi all, I am wondering if do exist a function in R that allow me to sample or choose randomly the rows (i.e., samples) inside a given matrix. Thank you very much in advance. Cheers, -- G

Re: [R] random sampling inside a dataset

2012-09-13 Thread Gian Maria Niccolò Benucci
> > Anna Freni Sterrantino > Department of Statistics > University of Bologna, Italy > via Belle Arti 41, 40124 BO. > -- > *Da:* Gian Maria Niccolò Benucci > *A:* r-help@r-project.org > *Inviato:* Giovedì 13 Settembre 2012 10:42 > *Oggetto:* [R] ran

Re: [R] random sampling inside a dataset

2012-09-13 Thread Berend Hasselman
On 13-09-2012, at 10:42, Gian Maria Niccolò Benucci wrote: > Hi all, > > I am wondering if do exist a function in R that allow me to sample or > choose randomly the rows (i.e., samples) inside a given matrix. Use sample. Like this for example A <- matrix(runif(8*4), nrow=8) A select.row <- sa

[R] random sampling inside a dataset

2012-09-13 Thread Gian Maria Niccolò Benucci
Hi all, I am wondering if do exist a function in R that allow me to sample or choose randomly the rows (i.e., samples) inside a given matrix. Thank you very much in advance. Cheers, -- Gian [[alternative HTML version deleted]] __ R-help@r-pro

Re: [R] random sampling but with caveats!

2011-09-08 Thread Jean-Christophe BOUËTTÉ
Hi there, It seems you got no answer. Maybe providing a reproducible example would help, as well as expressing your problem in more general terms. I am not an expert in sampling, but I would suggest (as does the help for sample) that you take a look at the sampling package, available on CRAN, and t

[R] random sampling but with caveats!

2011-09-08 Thread Rebecca Ross
Hi, I wonder if someone can help me. I have built a gam model to predict the presence of cold water corals and am now trying to evaluate my model by splitting my dataset into training/test datasets. In an ideal world I would use the sample() function to randomly select rows of data for me so fo

Re: [R] random sampling with levels and with replacement

2011-04-10 Thread taby gathoni
Andreas, Thanks alot. I  combined below and other suggestions given on r-help and it worked. --- On Fri, 4/8/11, Andreas Borg wrote: From: Andreas Borg Subject: Re: [R] random sampling with levels and with replacement To: tab...@yahoo.com Cc: "R help" Date: Friday, Apr

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread taby gathoni
Thanks Daniel, Its a long way but it will work. --- On Fri, 4/8/11, Daniel Malter wrote: From: Daniel Malter Subject: Re: [R] random sampling with levels and with replacement To: r-help@r-project.org Date: Friday, April 8, 2011, 10:08 AM If you want perfect equality, split the data

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread Andreas Borg
Hi, I am not perfectly sure what you want to do, but here is what I would do to maintain good/bad ratio in the sample (as Daniel posted, split the data and sample from the groups): df <- data.frame(V1 = 1:400, V2 = c(rep("good",360), rep("bad",40))) isGood <- which(df$V2=="good") isBad <- whi

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread Daniel Malter
If you want perfect equality, split the data in good and bad and sample from the two samples individually. On average, however, random sampling from the entire data will reproduce the proportion of good and bad in the data. hth, Daniel -- View this message in context: http://r.789695.n4.nabbl

[R] random sampling with levels and with replacement

2011-04-08 Thread taby gathoni
Dear all, i have a dataset of about 400 records , with a variable that has  two levels 40 bad and 360 good among other variables,how do i come up  with10 random samples that have the composition of as the main sample  but maintaining the 40 bad 360 good with replacement, i recently discovered th

Re: [R] random sampling steps in R

2011-03-10 Thread Ista Zahn
?Control and ?sample should get you started. Best, Ista On Thu, Mar 10, 2011 at 8:53 AM, taby gathoni wrote: > Dear all, > > Could someone assist me in random sampling steps/code in R? I have a main > sample  of  42 males and 165 females and I want to come up with about 1000 > samples of 20 ma

Re: [R] random sampling steps in R with replacement

2011-03-10 Thread Gerrit Eichner
Hello, Taby, for your (first) problem take a look at ?sample and its argument replace. Regards -- Gerrit On Thu, 10 Mar 2011, taby gathoni wrote: Please note is with replacement From: taby gathoni To: R help Sent: Thursday, March 10, 2011 11:53 AM Subject: [R] random sampling steps

[R] random sampling steps in R

2011-03-10 Thread taby gathoni
Dear all, Could someone assist me in random sampling steps/code in R? I have a main sample of 42 males and 165 females and I want to come up with about 1000 samples of 20 males and 20 females from this main sample. While at it, i would also like to come up Accuracy Ratios (ARs) with correspo

Re: [R] Random sampling while keeping distribution of nearest neighbor distances constant.

2009-08-12 Thread Emmanuel Levy
> But if the 1st order differences are the same, then doesn't it follow that > the 2nd, 3rd, ... order differences must be the same between the original and > the new "random" vector.  What am I missing? You are missing nothing sorry, I wrote something wrong. What I would like to be preserved is

Re: [R] Random sampling while keeping distribution of nearest neighbor distances constant.

2009-08-12 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: Emmanuel Levy [mailto:emmanuel.l...@gmail.com] > Sent: Wednesday, August 12, 2009 4:48 PM > To: Nordlund, Dan (DSHS/RDA) > Cc: r-h...@stat.math.ethz.ch; dev djomson > Subject: Re: [R] Random sampling while keeping distribution of nearest >

Re: [R] Random sampling while keeping distribution of nearest neighbor distances constant.

2009-08-12 Thread Emmanuel Levy
sday, August 12, 2009 3:05 PM >> To: r-h...@stat.math.ethz.ch >> Cc: dev djomson >> Subject: [R] Random sampling while keeping distribution of nearest neighbor >> distances constant. >> >> Dear All, >> >> I cannot find a solution to the following probl

Re: [R] Random sampling while keeping distribution of nearest ne

2009-08-12 Thread Emmanuel Levy
Thanks for your suggestion Ted, This would indeed work for the particular example I gave, but I am looking for a general solution. For example, if my values are: V=c(2,4,5,6) Then there would be two possibilities: 2,4,5,6 or 4,5,6,8 more generally, what I mean is that the matrix of distances betw

Re: [R] Random sampling while keeping distribution of nearest neighbor distances constant.

2009-08-12 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Emmanuel Levy > Sent: Wednesday, August 12, 2009 3:05 PM > To: r-h...@stat.math.ethz.ch > Cc: dev djomson > Subject: [R] Random sampling while keeping di

[R] Random sampling while keeping distribution of nearest neighbor distances constant.

2009-08-12 Thread Emmanuel Levy
Dear All,(my apologies if it got posted twice, it seems it didn't get through) I cannot find a solution to the following problem although I suppose this is a classic. I have a vector V of X=length(V) values comprised between 1 and N. I would like to get random samples of X values also compri

Re: [R] Random sampling while keeping distribution of nearest ne

2009-08-12 Thread Ted Harding
On 12-Aug-09 22:05:24, Emmanuel Levy wrote: > Dear All, > I cannot find a solution to the following problem although I imagine > that it is a classic, hence my email. > > I have a vector V of X values comprised between 1 and N. > > I would like to get random samples of X values also comprised bet

[R] Random sampling while keeping distribution of nearest neighbor distances constant.

2009-08-12 Thread Emmanuel Levy
Dear All, I cannot find a solution to the following problem although I imagine that it is a classic, hence my email. I have a vector V of X values comprised between 1 and N. I would like to get random samples of X values also comprised between 1 and N, but the important point is: * I would like

Re: [R] random sampling or random replacement

2009-06-25 Thread Girish A.R.
Joanne, [...snip...] x <- sample(1:2, 100) #without replacement Now I want x to contain to 20% missing data (NA). Could anyone help me how to do this? See if this helps: n <- length(x) x[sample(n, 0.2*n)] <- NA cheers, -Girish -- View this messag

Re: [R] random sampling or random replacement

2009-06-25 Thread Paul Chatfield
If you want to average 20% missing values then you could try it in 1 step, viz: sample(c(1:2, rep(NA, 2000)),100) Otherwise, 2 steps is preferable. Use code as below: sample(1:2,100)->kk kk[sample(1:100,20)]<-NA Paul -- View this message in context: http://www.nabble.com/ran

[R] random sampling or random replacement

2009-06-25 Thread Joanne Demmler
Dear R users, I'm trying to randomly recreate a real dataset with missing data and I'm not quite sure if I can use the sample command for this. I think it might be better to do it in 2 steps and randomly replace the sampled data with missing data... So something like this x <- sample(1:

Re: [R] Random sampling based on the observations

2009-03-24 Thread Arup
Thank you Adrian. Its working.Thank you so much. Take care =^D=) Cheers Arup Pramanik Business Analyst Redwood Associates Bangalore,India. Adrian Dusa wrote: > > On Tuesday 24 March 2009, you wrote: >> Hello!I am having a problem with Random sampling in R. I have used a >> syntax: mydata.sub

Re: [R] Random sampling based on the observations

2009-03-24 Thread Uwe Ligges
Arup wrote: Hello!I am having a problem with Random sampling in R. I have used a syntax: mydata.sub=sample(mydata,7,replace=FALSE,prob=NULL) which allows me to choose a random sample based on the variables(correct me if I am wrong!). Suppose I have 10 variable and if I use the above mentioned c

Re: [R] Random sampling based on the observations

2009-03-24 Thread Adrian Dusa
On Tuesday 24 March 2009, you wrote: > Hello!I am having a problem with Random sampling in R. I have used a > syntax: mydata.sub=sample(mydata,7,replace=FALSE,prob=NULL) which allows me > to choose a random sample based on the variables(correct me if I am > wrong!). Actually, no. You are sampling

[R] Random sampling based on the observations

2009-03-24 Thread Arup
Hello!I am having a problem with Random sampling in R. I have used a syntax: mydata.sub=sample(mydata,7,replace=FALSE,prob=NULL) which allows me to choose a random sample based on the variables(correct me if I am wrong!). Suppose I have 10 variable and if I use the above mentioned command then it