Re: [R] generate distribution based on summary data and add random noise

2022-02-03 Thread Bert Gunter
subject to the legally > binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ > > From: Bert Gunter > Sent: Thursday, February 3, 2022 5:10 PM > To: PIKAL Petr > Cc: R-help > Subject: Re: [R] generate distribution based on summary data and add > random noise > >

Re: [R] generate random numeric

2021-10-29 Thread Ken Peng
That's all right. Thanks. On Sat, Oct 30, 2021 at 12:29 AM Marc Schwartz wrote: > Ken Peng wrote on 10/29/21 2:39 AM: > > I saw runif(1) can generate a random num, is this the true random? > > > >> runif(1) > > [1] 0.8945383 > > > > What's the other better method? > > > > Thank you. > > > Hi, >

Re: [R] generate random numeric

2021-10-29 Thread Marc Schwartz via R-help
Ken Peng wrote on 10/29/21 2:39 AM: I saw runif(1) can generate a random num, is this the true random? runif(1) [1] 0.8945383 What's the other better method? Thank you. Hi, You do not indicate your use case, and that can be important. The numbers generated by R's default RNGs are "pseudo

Re: [R] generate random numeric

2021-10-29 Thread Jeff Newmiller
It is difficult to do "truly random" number generation with computers, but fortunately number sequences that appear random but progress consistently from an initial seed value (?set.seed) are actually much more useful for analysis purposes than true randomness is. On October 28, 2021 11:39:07 P

Re: [R] generate random numeric

2021-10-28 Thread Andrew Simmons
It might not be random, depending upon a seed being used (usually by set.seed or RNGkind). However, it's the best method for generating a random number within a specified range without weights. If you want weights, there are many other random number generation functions, most notably rnorm. You c

[R] generate random numeric

2021-10-28 Thread Ken Peng
I saw runif(1) can generate a random num, is this the true random? > runif(1) [1] 0.8945383 What's the other better method? Thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see h

Re: [R] generate average frame from different data frames

2021-10-24 Thread Luigi Marongiu
Thanks for the tip! I'll check it out. On Sun, Oct 24, 2021 at 8:07 AM Jim Lemon wrote: > > Hi Luigi, > In that case you will want a binomial confidence interval. > > Jim > > On Sun, Oct 24, 2021 at 4:39 PM Luigi Marongiu > wrote: > > > > Thank you. Sorry for the fuzziness of the question but I

Re: [R] generate average frame from different data frames

2021-10-23 Thread Jim Lemon
Hi Luigi, In that case you will want a binomial confidence interval. Jim On Sun, Oct 24, 2021 at 4:39 PM Luigi Marongiu wrote: > > Thank you. Sorry for the fuzziness of the question but I find it > difficult to give a proper definition of the problem. I have given a > graphical rendering on this

Re: [R] generate average frame from different data frames

2021-10-23 Thread Luigi Marongiu
Thank you. Sorry for the fuzziness of the question but I find it difficult to give a proper definition of the problem. I have given a graphical rendering on this post https://www.researchgate.net/post/How_to_find_95_CI_of_a_matrix_of_classification_data As you can see in the figure, there are dots

Re: [R] generate average frame from different data frames

2021-10-23 Thread Jim Lemon
Hi Luigi, I may be missing the point, but: matrix((z1+z2+z3)/3,ncol=10) gives you the mean rating for each item, and depending upon what distribution you choose, the confidence intervals could be calculated in much the same way. Jim On Sun, Oct 24, 2021 at 7:16 AM Luigi Marongiu wrote: > > Hel

[R] generate average frame from different data frames

2021-10-23 Thread Luigi Marongiu
Hello, I have a series of classifications of the same data. I saved this classification in a single dataframe (but it could be a list). X and Y are the variable and Z is the classification by three raters. `I` is the individual identifier of each entry: ``` z1 = c(0,0,0,0,0,1,0,0,0,2, 0,1,1,1,0,0,0

Re: [R] Generate oauth token using HTTR package in R

2021-08-03 Thread Mark Fowler
, but I do not know if it still is. Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10 From: Lac Will<mailto:outlook_789d32266f1fd...@outlook.com> Sent: Tuesday, August 3, 2021 4:10 AM To: r-help@r-project.org<mailto:r-help@r-project.org> Subject: [R] Ge

[R] Generate oauth token using HTTR package in R

2021-08-03 Thread Lac Will
Novice attempting R, as displayed below, to obtain an oauth token using HTTR package in R and have a status code of 401. Any insight as to the cause of this error and a resolution? Thanks in advance. # Status: 401 library(httr) base64_value <- "123456789=" response16 <- httr::POST

Re: [R] Generate Range of Correlations Matrix Bernoulli

2018-12-08 Thread إيمان إسماعيل محمد
Thank you for the clarification. ‫في السبت، 8 ديسمبر 2018 في 10:13 م تمت كتابة ما يلي بواسطة ‪Bert Gunter‬‏ <‪bgunter.4...@gmail.com‬‏>:‬ > Unless you are sending a private message, always include the list (which I > have cc'ed) in your reply, because, as here, individuals do not do private > con

Re: [R] Generate Range of Correlations Matrix Bernoulli

2018-12-08 Thread Bert Gunter
Unless you are sending a private message, always include the list (which I have cc'ed) in your reply, because, as here, individuals do not do private consulting and may be unwilling or unable to provide the help you seek. Bert Gunter ‪On Sat, Dec 8, 2018 at 10:33 AM ‫إيمان إسماعيل محمد‬‎ < eman

Re: [R] Generate Range of Correlations Matrix Bernoulli

2018-12-08 Thread Bert Gunter
I have no idea why your post was "rejected," nor even quite what you mean by that. But I believe your post may not receive any replies because you have failed to follow the posting guide linked below. I find it incomprehensible, but maybe others will be able to understand what you want. It may also

[R] Generate Range of Correlations Matrix Bernoulli

2018-12-08 Thread إيمان إسماعيل محمد
Hi all, I was wondering how can I construct range of correlations matrix that cover all space from dependent Multivariate Bernoulli (known Marginal Probabilities but unknown correlations) I have P's for every variable but unknown correlation between each pair I want to try range of applicable corre

Re: [R] Generate N random numbers with a given probability and condition

2018-07-12 Thread David Winsemius
> On Jul 12, 2018, at 12:44 AM, Göran Broström wrote: > > "Acceptance–Rejection Sampling from the Conditional Distribution of > Independent Discrete Random Variables, given their Sum", Statistics 34, pages > 247-257 Dear Go:ran; I'm fully retired with no subscriber academic library that I c

Re: [R] Generate N random numbers with a given probability and condition

2018-07-12 Thread Göran Broström
On 2018-07-05 00:21, Nelly Reduan wrote: Dear all, I would like to generate N random numbers with a given probability and condition but I'm not sure how to do this. For example, I have N = 20 and the vector from which to choose is seq(0, 10, 1). I have tested: x <- sample(seq(0, 10, 1), 20

Re: [R] Generate N random numbers with a given probability and condition

2018-07-11 Thread Duncan Murdoch
On 04/07/2018 6:21 PM, Nelly Reduan wrote: Dear all, I would like to generate N random numbers with a given probability and condition but I'm not sure how to do this. For example, I have N = 20 and the vector from which to choose is seq(0, 10, 1). I have tested: x <- sample(seq(0, 10, 1), 20,

Re: [R] Generate N random numbers with a given probability and condition

2018-07-11 Thread Jim Lemon
t; ____ > De : Jim Lemon > Envoyé : mardi 10 juillet 2018 17:44:13 > À : Nelly Reduan > Objet : Re: [R] Generate N random numbers with a given probability and > condition > > Hi Nell, > I may not have the right idea about this, but I think you

Re: [R] Generate N random numbers with a given probability and condition

2018-07-11 Thread Nelly Reduan
lements of a vector rather than to permute a vector ? Many thanks for your time. Have a nice day Nell De : Jim Lemon Envoyé : mardi 10 juillet 2018 17:44:13 À : Nelly Reduan Objet : Re: [R] Generate N random numbers with a given probability and condition Hi N

Re: [R] Generate N random numbers with a given probability and condition

2018-07-10 Thread Bert Gunter
__ > De : Rolf Turner > Envoyé : mercredi 4 juillet 2018 16:11:11 > À : Nelly Reduan > Cc : r-help@r-project.org > Objet : Re: [R] Generate N random numbers with a given probability and > condition > > > On 05/07/18 10:21, Nelly Reduan wrote: &g

Re: [R] Generate N random numbers with a given probability and condition

2018-07-10 Thread Jim Lemon
bility, I would like to generate N random positive > integers that sum to M and the integers would be selected from a uniform > distribution. > > > Many thanks for your time > > Nell > > > > De : Rolf Turner > Envoyé : mercredi 4

Re: [R] Generate N random numbers with a given probability and condition

2018-07-10 Thread Nelly Reduan
integers that sum to M and the integers would be selected from a uniform distribution. Many thanks for your time Nell De : Rolf Turner Envoyé : mercredi 4 juillet 2018 16:11:11 À : Nelly Reduan Cc : r-help@r-project.org Objet : Re: [R] Generate N random

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Marino David
Hi Chuck and all, Thanks for your response. It is really helpful for me. David 2018-07-07 7:30 GMT+08:00 Berry, Charles : > Sorry about the last incomplete post. Accidentally hit send. > > Meant to say that I was hoping that a correct, but obscure response from > me would motivate David to ste

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Berry, Charles
Sorry about the last incomplete post. Accidentally hit send. Meant to say that I was hoping that a correct, but obscure response from me would motivate David to step back and think about his problem long enough to see that it has an easy solution. Sorry if that was out-of-line. Chuck > On Ju

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Berry, Charles
> On Jul 6, 2018, at 3:31 PM, Duncan Murdoch wrote: > > On 06/07/2018 1:18 PM, Berry, Charles wrote: >> A liitle math goes along way. See below. >>> On Jul 5, 2018, at 10:35 PM, Marino David wrote: >>> >>> Dear Bert, >>> >>> I know it is a simple question. But for me, at current, I fail to

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Duncan Murdoch
On 06/07/2018 1:18 PM, Berry, Charles wrote: A liitle math goes along way. See below. On Jul 5, 2018, at 10:35 PM, Marino David wrote: Dear Bert, I know it is a simple question. But for me, at current, I fail to implement it. So, I ask for help here. It is not homework. Best, David 2018-

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Göran Broström
On 2018-07-06 19:18, Berry, Charles wrote: A liitle math goes along way. See below. On Jul 5, 2018, at 10:35 PM, Marino David wrote: Dear Bert, I know it is a simple question. But for me, at current, I fail to implement it. So, I ask for help here. It is not homework. Best, David 2018

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Berry, Charles
A liitle math goes along way. See below. > On Jul 5, 2018, at 10:35 PM, Marino David wrote: > > Dear Bert, > > I know it is a simple question. But for me, at current, I fail to implement > it. So, I ask for help here. > > It is not homework. > > Best, > > David > > 2018-07-06 13:32 GMT+08:0

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Marino David
Dear Ben, Thanks a lot for your reply. Best, David 2018-07-06 19:33 GMT+08:00 Ben Tupper : > Hi, > > I haven't any idea about what you ask, but I do know that Rseek.org is a > gold mine! Check out... > > https://rseek.org/?q=Bernoulli+random+variable > > Cheers, > Ben > > On Jul 6, 2018, at 1

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Ben Tupper
Hi, I haven't any idea about what you ask, but I do know that Rseek.org is a gold mine! Check out... https://rseek.org/?q=Bernoulli+random+variable Cheers, Ben > On Jul 6, 2018, at 1:35 AM, Marino David wrote: > > Dear Be

Re: [R] Generate random Bernoulli draws

2018-07-05 Thread Marino David
Dear Bert, I know it is a simple question. But for me, at current, I fail to implement it. So, I ask for help here. It is not homework. Best, David 2018-07-06 13:32 GMT+08:00 Bert Gunter : > Is this homework? > > (There is an informal no-homework policy on this list). > > Cheers, > Bert > > >

Re: [R] Generate random Bernoulli draws

2018-07-05 Thread Bert Gunter
Is this homework? (There is an informal no-homework policy on this list). Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Jul 5, 2018 at 10

[R] Generate random Bernoulli draws

2018-07-05 Thread Marino David
Dear All, I would like to generate N random Bernoulli draws given a probability function F(x)=1-exp(-2.5*x) in which x follows uniform distribution, say x~U(0,2). Can some one leave me some code lines for implementing this? Thanks in advance. David [[alternative HTML version deleted]]

Re: [R] Generate N random numbers with a given probability and condition

2018-07-04 Thread Rolf Turner
On 05/07/18 10:21, Nelly Reduan wrote: Dear all, I would like to generate N random numbers with a given probability and condition but I'm not sure how to do this. For example, I have N = 20 and the vector from which to choose is seq(0, 10, 1). I have tested: x <- sample(seq(0, 10, 1), 20,

Re: [R] Generate N random numbers with a given probability and condition

2018-07-04 Thread Jeff Newmiller
This looks like homework (which is off topic here per the Posting Guide). Also, please send your emails in plain text format to avoid us seeing your message differently than you do. On July 4, 2018 3:21:34 PM PDT, Nelly Reduan wrote: >Dear all, > >I would like to generate N random numbers with

[R] Generate N random numbers with a given probability and condition

2018-07-04 Thread Nelly Reduan
Dear all, I would like to generate N random numbers with a given probability and condition but I'm not sure how to do this. For example, I have N = 20 and the vector from which to choose is seq(0, 10, 1). I have tested: x <- sample(seq(0, 10, 1), 20, replace=TRUE, prob=rep(0.28, times=length(se

Re: [R] Generate simulated data respecting some conditions

2017-07-06 Thread Jeff Newmiller
Yes, definitely. However, this is so close to being legal R code that I feel you have not made any effort to translate it yourself, and this is the "R-help" mailing list, not the "R-do-my-work-for-me" mailing list. Is this homework? Have you read the "Introduction to R" document that is supplie

[R] Generate simulated data respecting some conditions

2017-07-06 Thread Marine Regis
Hello, Is it possible to generate simulated data that look like the attached figure? The curve in the figure can be obtained from this equation respecting some conditions: if(Temperature > T_min & Temperature < T_max){ a*( Temperature -T_min)*( Temperature -T_max) } else 0 T_min ~ Unif

[R] Generate correlated expontial distribution -- lamda please guide

2017-06-15 Thread Sunny Singha
Hi, I need to generate correlated (positive as well as negative) bivariate exponential distribution with rate of 1/5 or any rate I need some guidance here. Please help. Regards, Sunny __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] generate a vector of random numbers within confines of certain parameters

2016-08-02 Thread Bert Gunter
All floating point operations are done to machine precision -- roughly 16 digits. See ?.Machine . You can choose to round, truncate, or display to anything less than that that you care to. See also the digits parameter of ?options The rest of your post is ambiguous to me. But note that (all?/most

Re: [R] generate a vector of random numbers within confines of certain parameters

2016-08-02 Thread Jeff Newmiller
x <- rnorm( 2, 5, 2.5 ) The requirement for "random" is ill-specified because it omits mention of which random distribution you want (I assumed normal distribution above). The requirement for "decimal places" is ill-defined because floating point numbers are internally represented with mant

Re: [R] generate a vector of random numbers within confines of certain parameters

2016-08-02 Thread David L Carlson
-Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L Carlson Sent: Tuesday, August 2, 2016 2:40 PM To: Adrian Johnson; r-help Subject: Re: [R] generate a vector of random numbers within confines of certain parameters Try > set.seed(42) > x1 <- ro

Re: [R] generate a vector of random numbers within confines of certain parameters

2016-08-02 Thread David L Carlson
ian Johnson Sent: Tuesday, August 2, 2016 1:57 PM To: r-help Subject: [R] generate a vector of random numbers within confines of certain parameters Dear group, I am trying to generate a vector of random numbers for 20K observation. however, I want to generate numbers (with 6 decimal places) within th

[R] generate a vector of random numbers within confines of certain parameters

2016-08-02 Thread Adrian Johnson
Dear group, I am trying to generate a vector of random numbers for 20K observation. however, I want to generate numbers (with 6 decimal places) within the range of Std. Dev : 2-3 mean : 4-6 Is there a method to generate numbers with 6 decimal places under these parameters thank you. Adrian __

Re: [R] Generate list if sequence form two vector element

2016-06-23 Thread PIKAL Petr
; Cc: R-help Mailing List > Subject: Re: [R] Generate list if sequence form two vector element > > Hi Tanvir, > Not at all elegant, but: > > make.seq<-function(x) return(seq(x[1],x[2])) > apply(matrix(c(a,b),ncol=2),1,make.seq) > > Jim > > > On Wed, Jun 22, 2016 a

Re: [R] Generate list if sequence form two vector element

2016-06-22 Thread Jim Lemon
Hi Tanvir, Not at all elegant, but: make.seq<-function(x) return(seq(x[1],x[2])) apply(matrix(c(a,b),ncol=2),1,make.seq) Jim On Wed, Jun 22, 2016 at 5:32 PM, Mohammad Tanvir Ahamed via R-help wrote: > Hi, > I want to do the follow thing > > Input : > a <- c(1,3,6,9) > > > b<-c(10,7,20,2) > > >

[R] Generate list if sequence form two vector element

2016-06-22 Thread Mohammad Tanvir Ahamed via R-help
Hi, I want to do the follow thing Input : a <- c(1,3,6,9) b<-c(10,7,20,2) Expected outcome : d<-list(1:10,3:7,6:20,2:9) Thanks !! Tanvir Ahamed Göteborg, Sweden | mashra...@yahoo.com __ R-help@r-project.org mailing list -- To UNSUBS

Re: [R] generate levels with different number of replications with gl() function

2016-02-10 Thread David Barron
Why not use rep instead of gl: levels <- c('BR', 'CNS', 'CO', 'LE', 'ME', 'LC', 'OV', 'PR', 'RE') reps <- c(4, 6, 7, 6, 10, 9, 7, 2, 8) rep(levels, reps) David On 10 February 2016 at 05:02, hehsham alpukhity via R-help < r-help@r-project.org> wrote: > I am trying to use the function gl (generat

[R] generate levels with different number of replications with gl() function

2016-02-09 Thread hehsham alpukhity via R-help
I am trying to use the function gl (generate levels with different number of replications), generate different number of replications in each level.examplei have factor with this levels (BR,CNS ,CO,LE,ME,LC,OV,PR,RE),  and the replications is not the same , i want (4 replication for BR),( 6 repl

[R] Generate arrival of time based on uniform random number

2016-02-03 Thread smart hendsome via R-help
Hi everyone, I have problem regarding to generate arrival of time based on uniform random number. Let day0 = 0.383, lambda = 0.2612 1) Generate uniform random number (already settled) using the code below: set.seed(1234) rand.no <- function(n,itr){   matrix(runif(n*itr, 0, 1), nrow=n, ncol=itr) }

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Marc Schwartz
> On Sep 16, 2015, at 3:40 PM, Bert Gunter wrote: > > Nope. Take it back. I stand uncorrected. > >> system.time(z <-sample(1:10,1e6, rep=TRUE)) > user system elapsed > 0.045 0.001 0.047 > >> system.time(z <-sample.int(10,1e6,rep=TRUE)) > user system elapsed > 0.012 0.000 0.013

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Bert Gunter
Nope. Take it back. I stand uncorrected. > system.time(z <-sample(1:10,1e6, rep=TRUE)) user system elapsed 0.045 0.001 0.047 > system.time(z <-sample.int(10,1e6,rep=TRUE)) user system elapsed 0.012 0.000 0.013 sample() has to do subscripting in the general case; sample.int d

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Bert Gunter
Yes. Thanks Marc. I stand corrected. -- Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Wed, Sep 16, 2015 at 1:28 PM, Marc Schwartz wrote: > >> On Sep 16, 2015, at 1:06 PM, Bert Gunter wrote: >> >> Yikes!

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Marc Schwartz
> On Sep 16, 2015, at 1:06 PM, Bert Gunter wrote: > > Yikes! The uniform distribution is a **continuous** distribution over > an interval. You seem to want to sample over a discrete distribution. > See ?sample for that, as in: > > sample(1:4,100,rep=TRUE) > > ## or for this special case and fa

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Bert Gunter
Yikes! The uniform distribution is a **continuous** distribution over an interval. You seem to want to sample over a discrete distribution. See ?sample for that, as in: sample(1:4,100,rep=TRUE) ## or for this special case and faster sample.int(4,size=100,rep=TRUE) Cheers, Bert Bert Gunter "Da

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Marc Schwartz
> On Sep 16, 2015, at 12:11 PM, thanoon younis > wrote: > > Dear R- users > > I want to generate ordered categorical variable vector with 200x1 dimension > and from 1 to 4 categories and i tried with this code > > Q1=runif(200,1,4) the results are not just 1 ,2 3,4, but the results with > dec

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread David L Carlson
TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of thanoon younis Sent: Wednesday, September 16, 2015 12:11 PM To: r-help@r-project.org Subject: [R] generate ordered categorical variable in R Dear R- users I want to generate ordered categorical va

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Rui Barradas
Hello, Try ?sample. Hope this helps, Rui Barradas Em 16-09-2015 18:11, thanoon younis escreveu: Dear R- users I want to generate ordered categorical variable vector with 200x1 dimension and from 1 to 4 categories and i tried with this code Q1=runif(200,1,4) the results are not just 1 ,2 3,4

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Michael Dewey
If I understand correctly ?sample On 16/09/2015 18:11, thanoon younis wrote: Dear R- users I want to generate ordered categorical variable vector with 200x1 dimension and from 1 to 4 categories and i tried with this code Q1=runif(200,1,4) the results are not just 1 ,2 3,4, but the results wi

[R] generate ordered categorical variable in R

2015-09-16 Thread thanoon younis
Dear R- users I want to generate ordered categorical variable vector with 200x1 dimension and from 1 to 4 categories and i tried with this code Q1=runif(200,1,4) the results are not just 1 ,2 3,4, but the results with decimals like 1.244, 2.342,4,321 and so on ... My question how can i generate a

Re: [R] Generate a vector of values, given a vector of keys and a table?

2015-09-11 Thread David Wolfskill
On Fri, Sep 11, 2015 at 04:42:07PM +0200, peter dalgaard wrote: > Or change the data format slightly and use indexing: > > > l > keyval > [1,] "1.1" "1" > [2,] "1.9" "1" > [3,] "1.4" "15000" > [4,] "1.5" "2" > [5,] "1.15" "25000" > > v <- l[,2] > > names(v) <- l[,1] >

Re: [R] Generate a vector of values, given a vector of keys and a table?

2015-09-11 Thread peter dalgaard
Or change the data format slightly and use indexing: > l keyval [1,] "1.1" "1" [2,] "1.9" "1" [3,] "1.4" "15000" [4,] "1.5" "2" [5,] "1.15" "25000" > v <- l[,2] > names(v) <- l[,1] > x <- c("1.9", "1.9", "1.1", "1.1", "1.4", "1.4", "1.5", "1.5", "1.5", + "1.5") > v[x]

Re: [R] Generate a vector of values, given a vector of keys and a table?

2015-09-11 Thread David Wolfskill
On Thu, Sep 10, 2015 at 10:30:50PM -0700, Bert Gunter wrote: > ?match > > as in: > > > y <- lk_up[match(x,lk_up[,"key"]),"val"] > > y > [1] "1" "1" "1" "1" "15000" "15000" "2" > [8] "2" "2" "2" > ... Aye -- thank you very much! Peace, david -- David H. Wolfski

Re: [R] Generate a vector of values, given a vector of keys and a table?

2015-09-10 Thread Bert Gunter
?match as in: > y <- lk_up[match(x,lk_up[,"key"]),"val"] > y [1] "1" "1" "1" "1" "15000" "15000" "2" [8] "2" "2" "2" Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On

[R] Generate a vector of values, given a vector of keys and a table?

2015-09-10 Thread David Wolfskill
I apologize in advance: I must be overlooking something quite simple, but I'm failing to make progress. Suppose I have a "lookup table": Browse[2]> dput(lk_up) structure(c("1.1", "1.9", "1.4", "1.5", "1.15", "1", "1", "15000", "2", "25000"), .Dim = c(5L, 2L), .Dimnames = list( NU

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread William Dunlap
Look more at help(rep) and help(seq): > n <- 7 > rep(seq_len(n), each=4) [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 Bill Dunlap TIBCO Software wdunlap tibco.com On Sun, Apr 19, 2015 at 6:44 AM, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > >

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e. 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n (The spaces in the list are added only for clarity.) I can generate the list as follow

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e. 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n (The spaces in the list are added only for clarity.) I can generate the list as follow

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread SOUVIK BANDYOPADHYAY
Hi, You can use the apply group of functions n<-5 k<-4 unlist(lapply(1:n,rep, each=k)) # For vector output: sapply(1:n,rep, each=k) # For a matrix output Hope this helps Souvik On Sun, Apr 19, 2015 at 7:14 PM, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > > I am tryi

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e. 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n (The spaces in the list are added only for clarity.) I can generate the list as fo

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Boris Steipe
That would be the "each" argument to rep()... n <- 5 rep(1:n, each=4) [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 Cheers, B. On Apr 19, 2015, at 9:44 AM, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > > I am trying to generate a list of length 4n which consists of

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Gerrit Eichner
Hi, John, doesn't n <- lapply( 1:n, rep, each = 4) do what you need? Hth -- Gerrit On Sat, 18 Apr 2015, John Sorkin wrote: Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e.

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Sven E. Templer
In '?rep' find out about the 'each' argument. Also there is the function 'gl' which creates a factor and offers a shorter syntax for your problem. If n equals 5 use one of: rep(seq(5), each = 4) gl(5,4) On 19 April 2015 at 15:44, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Michael Dewey
On 19/04/2015 15:34, John Sorkin wrote: Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e. 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n (The spaces in the list are added only for c

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Ben Tupper
On Apr 19, 2015, at 9:44 AM, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > > I am trying to generate a list of length 4n which consists of the integers 1 > to n repeated in groups of four, i.e. > > 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n > Hi, Like this?

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Rmh
rep(1:n, each=4) Sent from my iPhone > On Apr 19, 2015, at 09:44, John Sorkin wrote: > > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > > I am trying to generate a list of length 4n which consists of the integers 1 > to n repeated in groups of four, i.e. > > 1,1,1,1, 2,2,2,2, 3,3,3,3

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Jeff Newmiller
You are not generating lists, you are generating vectors. Try rep( seq.int( n ), each= 4 ) --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e. 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n (The spaces in the list are added only for clarity.) I can generate the list as follow

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-19 Thread John Sorkin
Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am trying to generate a list of length 4n which consists of the integers 1 to n repeated in groups of four, i.e. 1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n (The spaces in the list are added only for clarity.) I can generate the list as follow

Re: [R] Generate random numbers under constrain

2014-11-27 Thread Mikhail Umorin
How about generating the uniform numbers sequentially and keep the running sum of all the previous numbers. At each step check if the newly generated random number plus the running sum > 1 discard the number and generate a new one, repeat the condition check. If the new number plus old sum < 1 a

Re: [R] Generate random numbers under constrain

2014-11-27 Thread Erich Neuwirth
You want random numbers within the n-dimensional simplex (sum xi <=1) The easiest solution of course would be creating n-dimensions vectors with iid uniform components on [0,1) and throwing away those violating the inequality. Since the volume of the n-dimensional simplex is 1/n! (factorial) this b

Re: [R] Generate random numbers under constrain

2014-11-27 Thread Jue Lin-Ye
Hello! I am relatively new using R, but this is my contribution to the answer. How about using a Monte-Carlo method. Generate m numbers in the support [0,1], where m>n. Then constrain by constructing a loop that takes every one of the elements in the m sized vector and select the ones that sum up t

Re: [R] Generate random numbers under constrain

2014-11-22 Thread David Winsemius
In the 2 and 3 vector case it is possible do define a fairly simple sampling space where this is possible. Consider the unit square where the sample space is the area where x+y <1. It generalizes to 3 dimensions with no difficulty. x= (0:100)/100 y= (0:100)/100 z=outer(x,y, function(x,y) 1-

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Boris Steipe
Of course they are random. But they can't all be randomly picked from [0,1). By scaling them, one is effectively scaling the interval from which they are picked. B. Nb: the scaling procedure will work for any probability distribution. On Nov 22, 2014, at 10:54 AM, Ranjan Maitra wrote: > I d

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Ranjan Maitra
I don't understand this discussion at all. n random numbers constrained to have sum <=1 are still random. They are not all independent. That said, the original poster's question is ill=formed since there can be multiple distributions these random numbers come from. best wishes, Ranjan On Sa

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Boris Steipe
These are contradictory requirements: either you have n random numbers from the interval [0,1), then you can't guarantee anything about their sum except that it will be in [0,n). Or you constrain the sum, then your random numbers cannot be random in [0,1). You could possibly scale the random num

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Bert Gunter
(Hit send key by accident before I was finished ...) Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Sat, Nov 22, 2014 at 7:14 AM, Bert Gunter wrote: > Well, if th

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Bert Gunter
Well, if their sum must be < 1 they ain't random... But anyway... given n randnums <- function(n) { Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Sat, Nov 22,

[R] Generate random numbers under constrain

2014-11-22 Thread Ragia Ibrahim
Dear all, I use R 3.1.1 for Windows. kindly how can I generate n number of random numbers with probability from [0,1] and their sum must not be more than one thanks in advance Ragia [[alternative HTML version deleted]]

Re: [R] Generate sequence of date based on a group ID

2014-10-08 Thread arun
If the `ids` are ordered as shown in the example, perhaps you need tbl <- table(df$id) rep(seq(as.Date("2000-01-01"), length.out=length(tbl), by=1), tbl) [1] "2000-01-01" "2000-01-01" "2000-01-01" "2000-01-01" "2000-01-01" [6] "2000-01-02" "2000-01-02" "2000-01-02" "2000-01-02"

Re: [R] Generate sequence of date based on a group ID

2014-10-08 Thread Adams, Jean
Does this work for you? df$in1 <- 0 df$in1[match(unique(df$id), df$id)] <- 1 df$date <- as.Date("2000-01-01") + cumsum(df$in1) - 1 Jean On Wed, Oct 8, 2014 at 2:57 AM, Kuma Raj wrote: > I want to generate a sequence of date based on a group id(similar IDs > should have same date). The id varia

[R] Generate sequence of date based on a group ID

2014-10-08 Thread Kuma Raj
I want to generate a sequence of date based on a group id(similar IDs should have same date). The id variable contains unequal observations and the length of the data set also varies. How could I create a sequence that starts on specific date (say January 1, 2000 onwards) and continues until the e

Re: [R] Generate quasi-random positive numbers

2014-08-05 Thread Martyn Byng
example the Sobol generator from http://cran.r-project.org/web/packages/randtoolbox/index.html. Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Frederico Mestre Sent: 05 August 2014 11:28 To: r-help@r-project.org Subject: [R

Re: [R] Generate quasi-random positive numbers

2014-08-05 Thread Ted Harding
On 05-Aug-2014 10:27:54 Frederico Mestre wrote: > Hello all: > > Is it possible to generate quasi-random positive numbers, given a standard > deviation and mean? I need all positive values to have the same probability > of selection (uniform distribution). Something like: > > runif(10, min = 0, m

[R] Generate quasi-random positive numbers

2014-08-05 Thread Frederico Mestre
Hello all: Is it possible to generate quasi-random positive numbers, given a standard deviation and mean? I need all positive values to have the same probability of selection (uniform distribution). Something like: runif(10, min = 0, max = 100) This way I'm generating random positive numbers fro

Re: [R] Generate data follows space-time clustered inhomogeneous Poisson point process in 3D space

2014-06-27 Thread Jeff Newmiller
Please read the Posting Guide mentioned at the bottom of this out any other email on this list. You have repeatedly abused this list this week. - posting in HTML - cross-posting to multiple lists - duplicate posts - off-topic subjects You have not been getting much response due to this behavior,

[R] Generate data follows space-time clustered inhomogeneous Poisson point process in 3D space

2014-06-27 Thread Ferra Xu
I'd like to know how can I generate a data set for space-time clustered  inhomogeneous Poisson processin a 3D space without having any previous data in R? Actually I need to generate points in a rectangle cube, and these points are not uniformly distributed in space (they show clusters). Thanks,

  1   2   3   4   >