On Thu, Feb 14, 2008 at 7:53 PM, dinesh kumar <[EMAIL PROTECTED]> wrote: > Hi R users > I am a new user in the field of R. > I want to subset or reshape a data.frame. > For example I have a matrix like > > A B C D E F G > a 1 2 3 4 5 6 7 > b 4 6 8 9 5 5 6 > c 3 4 4 4 3 3 6 > d 1 2 4 6 8 8 9 > e 5 6 7 8 9 2 3 > > I want to reshape the matrix in this format > > Row Col Value > a D 4 > a E 5 > a F 6 > . . .. > e E 9 > > I want only the pair which pass a threshold for example >3.
library(reshape) molten <- melt(mymatrix) subset(molten, value > 3) You can learn more about the reshape package at http://had.co.nz/reshape Hadley -- http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.