Re: [R] partially sorting?

2009-07-29 Thread Dominik.Cullmann
 x -
+ matrix(c(1239,10,10,10,10,1234,10,10,10,10,1500,11,11,11,11,1001,11,11,11,11,
+  
+ 1009,11,11,11,11,1344,12,12,12,12,1349,12,12,12,12,1458,13,13,13,13),8,5,byrow
+ = T) 
 x[order(x[,1]),]
 [,1] [,2] [,3] [,4] [,5]
[1,] 1001   11   11   11   11
[2,] 1009   11   11   11   11
[3,] 1234   10   10   10   10
[4,] 1239   10   10   10   10
[5,] 1344   12   12   12   12
[6,] 1349   12   12   12   12
[7,] 1458   13   13   13   13
[8,] 1500   11   11   11   11


see ?order
regards, nik

--
Andreas Dominik Cullmann
Forstliche Versuchs- und Forschungsanstalt 
Wonnhalde 4 
79100 Freiburg 
Tel. +49 761 4018 204 
Email: dominik.cullm...@forst.bwl.de mailto:dominik.cullm...@forst.bwl.de 
Homepage: www.fva-bw.de http://www.fva-bw.de 


 -Ursprüngliche Nachricht-
 Von: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] Im Auftrag von ashley2000
 Gesendet: Mittwoch, 29. Juli 2009 03:44
 An: r-help@r-project.org
 Betreff: [R] partially sorting?
 
 
 Dear all,
 
 x -
 matrix(c(1239,10,10,10,10,1234,10,10,10,10,1500,11,11,11,11,10
 01,11,11,11,11,
  
 1009,11,11,11,11,1344,12,12,12,12,1349,12,12,12,12,1458,13,13,
 13,13),8,5,byrow
 = T) 
 
  x
  [,1] [,2] [,3] [,4] [,5]
 [1,] 1239   10   10   10   10
 [2,] 1234   10   10   10   10
 [3,] 1500   11   11   11   11
 [4,] 1001   11   11   11   11
 [5,] 1009   11   11   11   11
 [6,] 1344   12   12   12   12
 [7,] 1349   12   12   12   12
 [8,] 1458   13   13   13   13
 
 I tried to sort by 1st column, but stayed the other columns 
 as they were. I
 mean
 
 
 
  [,1] [,2] [,3] [,4] [,5]
 [2,] 1234   10   10   10   10
 [1,] 1239   10   10   10   10
 --
 [4,] 1001   11   11   11   11
 [5,] 1009   11   11   11   11
 [3,] 1500   11   11   11   11
 --
 [6,] 1344   12   12   12   12
 [7,] 1349   12   12   12   12
 --
 [8,] 1458   13   13   13   13
 
 
 
 any suggestions?
 
 thanks 
 
 ashley
 -- 
 View this message in context: 
 http://www.nabble.com/partially-sorting--tp24710996p24710996.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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.
 

__
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.


[R] recursive List extraction question

2008-12-12 Thread Dominik.Cullmann
Dear all,
I've got a list 
L - list(L1 = list
  (foo = bar
   , SL = NULL
   )
  , L2 = list
  (
   foo = bar
   , SL = list
   (SSL1 = list
(DF = data.frame(val = 21, foo = bar)
 , DFOO = list(foo = foo, bar = bar)
 )
, SSL2 = list
(DF = data.frame(val = 22, foo = bar)
 , DFOO = list(foo = foo, bar = bar)
 )
)

   )
  , L3 = list
  (
   foo = bar
   , SL = list
   (SSL1 = list
(DF = data.frame(val=31, foo=bar)
 , DFOO = list(foo=foo, bar=bar)
 )
)
   )
  )
from which I'ld like to extract the values 21,22 and 31.

lapply(
   lapply(
  lapply(
 lapply(L, [[,SL)
 ,[[,1)
  ,[[,DF)
   ,[[,val) 

gives me 21 and 31. Because of lapply(...,[[,1), it searches  through
the first element of each SL, which are the SSL1. It misses SSL2. Is
there a way to replace the ,[[,1), with a regex or the like to get the
job done? Does anybody now any other solution? 
Thanks and regards,
Dominik


--
Andreas Dominik Cullmann
Forstliche Versuchs- und Forschungsanstalt 
Wonnhalde 4 
79100 Freiburg 
Tel. +49 761 4018 204 
Email: dominik.cullm...@forst.bwl.de
mailto:dominik.cullm...@forst.bwl.de 
Homepage: www.fva-bw.de http://www.fva-bw.de 

__
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.