gt; Bert
>>
>>
>> Why not just
>> > make X be a function explicitly? That is,
>> >
>> > X<- function() runif(length(lT), lT, uT)
>> >
>> > Then use X() to call the function where you were previously using X.
>> >
>> > Duncan Murdoch
n 1:length(lT)) runif(1, lT[i], uT[i])
>>
>> So that I can use X as a variable for multiple runs and
>> each run new random values are used.
>>
>> thank you
>> Johannes
>>
>> Original-Nachricht
>> >Datum: Wed, 10 Aug 2011 08:19
>
> Duncan Murdoch
>>
>> I thought about something like:
>> X<- for (i in 1:length(lT)) runif(1, lT[i], uT[i])
>>
>> So that I can use X as a variable for multiple runs and
>> each run new random values are used.
>>
>> thank you
>&
iginal-Nachricht
> Datum: Wed, 10 Aug 2011 08:19:07 -0500
> Von: Jean V Adams
> An: "Johannes Radinger"
> CC: r-help@r-project.org
> Betreff: Re: [R] function runif in for loop
> Johannes,
>
> You have the loop set up right, you just need to a
Original-Nachricht
> Datum: Wed, 10 Aug 2011 09:38:38 -0400
> Von: Duncan Murdoch
> An: Johannes Radinger
> CC: r-help@r-project.org
> Betreff: Re: [R] function runif in for loop
> On 10/08/2011 7:28 AM, Johannes Radinger wrote:
> > Hello,
>
inal-Nachricht
> Datum: Wed, 10 Aug 2011 08:19:07 -0500
> Von: Jean V Adams
> An: "Johannes Radinger"
> CC: r-help@r-project.org
> Betreff: Re: [R] function runif in for loop
> Johannes,
>
> You have the loop set up right, you just need to add indexing to
Following the suggestion by Duncan Murdoch, this should work for you.
X <- runif(length(lT), lT, uT)
Jean
From:
"Johannes Radinger"
To:
Jean V Adams
Cc:
r-help@r-project.org
Date:
08/10/2011 08:40 AM
Subject:
Re: [R] function runif in for loop
Jean,
thank you for your answe
On 10/08/2011 7:28 AM, Johannes Radinger wrote:
Hello,
I'd like to perform a regression using MCMCregress (MCMCpack).
One variable therefore should be a function rather than a variable:
I want to use X as an input and X should be defined as a random number between
to values. Therefore I want t
Johannes,
You have the loop set up right, you just need to add indexing to refer to
the looping variable, i.
lT <- sample(1:10)
uT <- sample(21:30)
X <- numeric(length(lT))
for (i in 1:length(lT)) X[i] <- runif(1, lT[i], uT[i])
X
Note that I changed the name of the result from T to X, because
9 matches
Mail list logo