Re: [R] Split data frame based on Class

2009-05-18 Thread Kushantha Perera
Try split()! ?split e.g > a var1 var2 var3 1 a14 2 a25 3 a36 4 b47 5 b58 6 a69 7 b7 NA 8 c82 9 c95 10b34 11a24 12a14 13c23 14c54

Re: [R] transposing/rotating XY in a 3D array

2009-05-15 Thread Kushantha Perera
6 , , 2 [,1] [,2] [,3] [1,]789 [2,] 10 11 12 Good day! Kushantha Perera | Amba Research Ph +94 11 235 6281 | Mob +94 77 222 4373 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com -Original Message- From: r-help-boun...@r-pro

Re: [R] subset data

2009-05-05 Thread Kushantha Perera
Try, data[data$id%in%selected.id,] Good day! Kushantha -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of abdul kudus Sent: Wednesday, May 06, 2009 10:12 AM To: r-help@r-project.org Subject: [R] subset data Dear all, > data <- data.

Re: [R] search through a matrix

2009-04-21 Thread Kushantha Perera
row() gives the row number of each element of the matrix, similarly col() gives the column number. By definition, diagonal elements are the elements correspond to same row and column numbers. That's how it works... x <- matrix(1:12, 3, 4) > x [,1] [,2] [,3] [,4] [1,] 12963 [2,]