Re: [R] Select 5 identical numbers
read up on ?sample Dan Daniel Nordlund Bothell, WA USA > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Alaios > Sent: Monday, January 20, 2014 10:12 PM > To: Alaios; R-help@r-project.org > Subject: Re: [R] Select 5 identical numbers > > Hi, > I want from a vector containing has like 1000 elements to select X of it > randomly but with never selecting the same element again. Each one should > be unique element of the vector. > Is this more precise now? > > Regards > Alex > > > > > On Monday, January 20, 2014 7:54 PM, Alaios wrote: > > Dear all, > I would like to select from a vector of 10 elements, 5 of those that are > identical. > How can I do that in R? I guess one way would be to taking random numbers > and see if that appeared again. Is though there a more straightforward > approach? > > Regards > Alex > [[alternative HTML version deleted]] > > __ > R-help@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. > [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Select 5 identical numbers
Hi, I want from a vector containing has like 1000 elements to select X of it randomly but with never selecting the same element again. Each one should be unique element of the vector. Is this more precise now? Regards Alex On Monday, January 20, 2014 7:54 PM, Alaios wrote: Dear all, I would like to select from a vector of 10 elements, 5 of those that are identical. How can I do that in R? I guess one way would be to taking random numbers and see if that appeared again. Is though there a more straightforward approach? Regards Alex [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Select 5 identical numbers
But just noting the usual floating point stuff, Jim's approach might run into problems depending on what you have as "numbers" and what is meant by "identical." Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch On Mon, Jan 20, 2014 at 9:48 AM, jim holtman wrote: > Use 'table' to count the occurances and then select the one that has a > count of 5. > > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > > > On Mon, Jan 20, 2014 at 12:07 PM, Alaios wrote: >> Dear all, >> I would like to select from a vector of 10 elements, 5 of those that are >> identical. >> How can I do that in R? I guess one way would be to taking random numbers >> and see if that appeared again. Is though there a more straightforward >> approach? >> >> Regards >> Alex >> [[alternative HTML version deleted]] >> >> __ >> R-help@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. > > __ > R-help@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. __ R-help@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.
Re: [R] Select 5 identical numbers
Use 'table' to count the occurances and then select the one that has a count of 5. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Jan 20, 2014 at 12:07 PM, Alaios wrote: > Dear all, > I would like to select from a vector of 10 elements, 5 of those that are > identical. > How can I do that in R? I guess one way would be to taking random numbers and > see if that appeared again. Is though there a more straightforward approach? > > Regards > Alex > [[alternative HTML version deleted]] > > __ > R-help@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. __ R-help@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.
[R] Select 5 identical numbers
Dear all, I would like to select from a vector of 10 elements, 5 of those that are identical. How can I do that in R? I guess one way would be to taking random numbers and see if that appeared again. Is though there a more straightforward approach? Regards Alex [[alternative HTML version deleted]] __ R-help@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.