Repeating a function in R

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Repeating a function in R

shan-2
This post has NOT been accepted by the mailing list yet.
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Repeating a function in R

Daniel Malter
You can just tell the function to create 1000 random numbers. See ?runif for the specifics. The arguments are n, min, and max. 'n' is the one you are looking for.

Da.
Reply | Threaded
Open this post in threaded view
|

Re: Repeating a function in R

Daniel Malter
In reply to this post by shan-2
If you want to repeat an entire function, use replicate as in

replicate(15,sapply(1,function(x) runif(x)))

Here, sapply(1,function(x) runif(x)) draws on uniformly distributed variable. replicate(15,...) is the wrapper function that tells to do this 15 times. The benefit here is that you can replicate a more complex function. However, if you just need 1000 random draws, I would use the easier approach I suggested above.

Best,
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: Repeating a function in R

Uwe Ligges-3
In reply to this post by Daniel Malter


On 02.07.2011 20:51, Daniel Malter wrote:
> You can just tell the function to create 1000 random numbers. See ?runif for
> the specifics. The arguments are n, min, and max. 'n' is the one you are
> looking for.

Thanks for providing help on R-help, but for the future please

- respond to the OP rather than to the list only

- cite the OP's message so that anybody else on this mailing list
understand the context of your message.

Best,
Uwe Ligges




> Da.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Repeating-a-function-in-R-tp3640508p3640966.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Repeating a function in R

Daniel Malter
Thanks, Uwe, for sending me this the second time. I send my responses through nabble. So #1 does not seem to be an option; #2 I sometimes forget.

Regards,
Daniel

Uwe Ligges-3 wrote
On 02.07.2011 20:51, Daniel Malter wrote:
> You can just tell the function to create 1000 random numbers. See ?runif for
> the specifics. The arguments are n, min, and max. 'n' is the one you are
> looking for.

Thanks for providing help on R-help, but for the future please

- respond to the OP rather than to the list only

- cite the OP's message so that anybody else on this mailing list
understand the context of your message.

Best,
Uwe Ligges




> Da.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Repeating-a-function-in-R-tp3640508p3640966.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Repeating a function in R

Uwe Ligges-3


On 05.07.2011 16:47, Daniel Malter wrote:
> Thanks, Uwe, for sending me this the second time.

Daniel,

I do not track names, sorry for posting twice.


 > I send my responses through nabble.

Great, so you found the main problem already.


> So #1 does not seem to be an option;

It is an option: if Nabble can't do it (and I really want to know if it
can), just use a more appropriate tool.


> #2 I sometimes forget.

Time to choose a tool that offers this by default so you can't forget.

Best wishes,
Uwe



> Regards,
> Daniel
>
>
> Uwe Ligges-3 wrote:
>>
>> On 02.07.2011 20:51, Daniel Malter wrote:
>>> You can just tell the function to create 1000 random numbers. See ?runif
>>> for
>>> the specifics. The arguments are n, min, and max. 'n' is the one you are
>>> looking for.
>>
>> Thanks for providing help on R-help, but for the future please
>>
>> - respond to the OP rather than to the list only
>>
>> - cite the OP's message so that anybody else on this mailing list
>> understand the context of your message.
>>
>> Best,
>> Uwe Ligges
>>
>>
>>
>>
>>> Da.
>>>
>>> --
>>> View this message in context:
>>> http://r.789695.n4.nabble.com/Repeating-a-function-in-R-tp3640508p3640966.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> ______________________________________________
>>> [hidden email] 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.
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Repeating-a-function-in-R-tp3640508p3646160.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.