[R] how to extract the column name or value from the numerical value of the matrix
Dear sir, i have a matrix like x-c(1:20) A-matrix(x,4,5) A [,1] [,2] [,3] [,4] [,5] [1,]159 13 17 [2,]26 10 14 18 [3,]37 11 15 19 [4,]48 12 16 20 I want to extract the column value for the matrix value 11... or the row value for 14.. how it is possible? thanks for your help with regards, boopathy. Thirumalai Shanmuha Boopathy, Zimmer no : 07-15, Rütscher strasse 165, 52072 Aachen . Germany. Home zone : 0049 - 241 - 9813409 Mobile zone : 0049 - 176 - 23567867 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to extract the column name or value from the numerical value of the matrix
look at ?col and ?row. One way to use them is: col(A)[A==11] row(A)[A==14] hope this helps, Greg Snow, Ph.D. Statistical Data Center, LDS Hospital Intermountain Health Care [EMAIL PROTECTED] (801) 408-8111 shanmuha boopathy [EMAIL PROTECTED] 09/19/05 01:30PM Dear sir, i have a matrix like x-c(1:20) A-matrix(x,4,5) A [,1] [,2] [,3] [,4] [,5] [1,]159 13 17 [2,]26 10 14 18 [3,]37 11 15 19 [4,]48 12 16 20 I want to extract the column value for the matrix value 11... or the row value for 14.. how it is possible? thanks for your help with regards, boopathy. Thirumalai Shanmuha Boopathy, Zimmer no : 07-15, Rütscher strasse 165, 52072 Aachen . Germany. Home zone : 0049 - 241 - 9813409 Mobile zone : 0049 - 176 - 23567867 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to extract the column name or value from the numerical value of the matrix
On Mon, 2005-09-19 at 12:30 -0700, shanmuha boopathy wrote: Dear sir, i have a matrix like x-c(1:20) A-matrix(x,4,5) A [,1] [,2] [,3] [,4] [,5] [1,]159 13 17 [2,]26 10 14 18 [3,]37 11 15 19 [4,]48 12 16 20 I want to extract the column value for the matrix value 11... or the row value for 14.. how it is possible? thanks for your help with regards, boopathy. Why did you copy r-devel? r-help is the appropriate forum. See ?which and take note of the 'arr.ind' argument: which(A == 11, arr.ind = TRUE) row col [1,] 3 3 which(A == 14, arr.ind = TRUE) row col [1,] 2 4 HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html