[R] Create Matrix with Float32 values

2011-06-01 Thread Chris English
Dear R_Help: The following gives me a matrix with integer values. z= matrix(rep(10:1, each= 10), ncol= 10, byrow=TRUE)> str(z) int [1:10, 1:10] 10 9 8 7 6 5 4 3 2 1 ... How do I specify that I want Float32 values instead. Thanks,Chris

Re: [R] for loop populate matrix

2011-05-10 Thread Chris English
@hotmail.com > CC: r-help@r-project.org > > Why loop? > > matrix(rep(3:0, each = 5), ncol = 5, byrow = TRUE) > [,1] [,2] [,3] [,4] [,5] > [1,] 3 3 3 3 3 > [2,] 2 2 2 2 2 > [3,] 1 1 1 1 1 > [4,] 0 0 0 0 0 > > HTH, > Dennis > > On Tue, May 10, 2011 at 11:

[R] for loop populate matrix

2011-05-10 Thread Chris English
Dear List, I am trying to populate a matrix using a for loop.This works. > four<- matrix(nrow=4,ncol=5)> for (j in 1:ncol(four)){+ for (i in > 1:nrow(four)){+ four[i,j]<-i-1}+ }> print(four)     [,1] [,2] [,3] [,4] > [,5][1,]    0    0    0    0    0[2,]    1    1    1    1    1[3,]    2    2