[R] For Subset or Reshaping the Table

Henrique Dallazuanna wwwhsd at gmail.com
Fri Feb 15 11:10:16 CET 2008


Try this:

cbind(Row=rownames(x), stack(x)[,2:1])[cbind(Row=rownames(x),
stack(x)[,2:1])[,3]>3,]

On 14/02/2008, dinesh kumar <barupal at gmail.com> 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.
>
>  Please help me.
>
>  Dinesh
>
>
>
>
>
>  --
>  Dinesh Kumar Barupal
>  Research Associate
>  Metabolomics Fiehn Lab
>  UCD Genome Center
>  451 East Health Science Drive
>  GBSF Builidng
>  University of California
>  DAVIS
>  95616
>  http://fiehnlab.ucdavis.edu/staff/kumar
>
>         [[alternative HTML version deleted]]
>
>  ______________________________________________
>  R-help at 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.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list