[R] help on understanding a code

2009-06-02 Thread Hongyuan Cao
Dear R user, I am trying to understand this following code. Basically it's using a permutation method to calculate p value. But I would like to know exactly how the permutation works. #calculates null statistics tt0 <- 0 set.seed(123) B <- 100 for(i in 1:B) { v <- sample(y) tt0 <- c(tt0,ttest(dat

[R] convert the contents of a date.frame to a matrix

2009-05-31 Thread Hongyuan Cao
Dear R user, I am trying to convert the contents of a date.frame to a matrix. Since there are negative values in the date.frame, when I use data.matrix(x, rownames.force = NA), the resulting matrix is not the same as the original one. Basically I think R treats the numbers in the date.frame as cha