[R] p value for joint probability

Petr Savicky savicky at praha1.ff.cuni.cz
Tue Feb 1 09:05:06 CET 2011


On Mon, Jan 31, 2011 at 09:42:27PM +0100, moleps wrote:
> Dear all,
> 
> Given
> 
> rr<-data.frame(r1<-rnorm(1000,10,5),r2<-rnorm(1000,220,5))
> 

Hello.

There is already an answer to your question. However, i think
that the above command works in a different way than you
expect. The embedded assignments create vectors r1, r2 and
the names of columns are derived from the whole expressions
"r1<-rnorm(1000,10,5)" and "r2<-rnorm(1000,220,5)". If there
are no other variables, then you get

  rr<-data.frame(r1<-rnorm(1000,10,5),r2<-rnorm(1000,220,5))
  ls()

  [1] "rr" "r1" "r2"

  rr[1:3, ]

    r1....rnorm.1000..10..5. r2....rnorm.1000..220..5.
  1                 8.639778                  227.3891
  2                17.477301                  227.4780
  3                 5.640543                  227.7373

If r1, r2 should be the names of the columns, then use named
arguments in the call of the function data.frame()

  rr<-data.frame(r1=rnorm(1000,10,5),r2=rnorm(1000,220,5))
  rr[1:3, ]

            r1       r2
  1 12.3274362 224.7632
  2 13.1347464 214.3805
  3  0.7495177 219.6179

Petr Savicky.



More information about the R-help mailing list