[R] (no subject)

Liviu Andronic landronimirc at gmail.com
Mon Feb 15 22:33:39 CET 2010


Hello
You are more likely to get help if you provide a subject more
informative than "no subject".

On 2/15/10, hussain abu-saaq <hussainib1 at hotmail.com> wrote:
>   is there a good notes for loops(if else  and while) in r.
>
Check this [1][3], but also the R manuals [2].

[1] http://www.r-project.org/doc/Rnews/Rnews_2008-1.pdf
[2] http://www.r-project.org/
[3] http://www.statmethods.net/management/controlstructures.html


>  I have a code written in Matlab and I tried to rewrite it in R but it does not give me the write result . for example in matlab the result is (1 2 3 4)
>   In r it is give my only 2
>
Can you give an example that we can reproduce? This one is too vague
to be of any help.


>  One more question if I have variable,lets say x and I use it in a loop and I update x each time in the loop . How can I get a vector for all X's.
>

Try this
> x <- NULL
> for(i in 1:10) x[i] <- mean(rnorm(100))
> x
 [1] -0.0045593  0.1730067  0.0395593  0.0232542 -0.0195095 -0.0475081
 0.2062105  0.0104414  0.0119292 -0.0011240

Liviu



More information about the R-help mailing list