Skip to content

[R-gui] Using runif function in R

4 messages · shweta, Dirk Eddelbuettel, Philippe GROSJEAN

#
Hi ,

I was trying to generate random data in R using the runif function. But 
I am not sure how do I combine the x and y to get a 2d array/matrix in a 
variable z.
As seen below I am getting the same numbers in x as 1 and in y as 2.1 
respectively. I would like to get different & random numbers in x & y.

Please let me know.

x <- array(runif(N,1),dim=c(N,1))
 > x
    [,1]
[1,]    1
[2,]    1
[3,]    1
[4,]    1
[5,]    1
[6,]    1
[7,]    1
[8,]    1
[9,]    1
[10,]    1
 > y <- array(2*x + runif(N,1)/10)
 > y
[1] 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2.1

Thanks & Regards,
Shweta.
2 days later
#
Shweta,

Just three days ago, in a random act of kindness, Charilaos told you in no
uncertain terms 

   PS: Not sure what this has to do with GUI though, isn't that more  
   appropriate to R-help instead of r-sig-gui?

Which part of this was unclear?

Charilaos also told you what you were doing wrong with your call to runif.
You are still making the same mistake.

Please go back and read his reply.  And please stop posting material that has
nothing to do with R and GUIs to the list devoted to R and GUIs.  

Thanks, Dirk
#
Hello All,

Sorry, this is my fault! But anyway, please, do post general questions 
to R-Help mailing list, and reserve R-SIG-GUI for GUI-specific questions 
on R.
Have a nice day,

Philippe

..............................................<?}))><........
  ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..............................................................
shweta wrote: