[R] to extract a section of the matrix

Daniel Malter daniel at umd.edu
Thu Aug 13 04:29:03 CEST 2009


x=c("blah","blub","bleep","foo")
y=rnorm(4)

yourdata=data.frame(x,y)
yourdata

newdata=yourdata[order(y),]
newdata

thisiswhatyouwant=newdata[1:2,]
thisiswhatyouwant


hth,
daniel 


-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von Inchallah Yarab
Gesendet: Wednesday, August 12, 2009 11:53 AM
An: r-help at r-project.org
Betreff: [R] to extract a section of the matrix

HI,
i have this matrix and i want to extract  a section of the matrix which
present the first and second value of optim position:
   OptimYear            LRPhase
PriorLRPosition                 OptimPosition            LRPosition   
5      2009                      1
1.15641679414676       0.33037984561357            1
6      2009                      1
1.05365365779321       0.282266634171568          1
7      2009                      1
0.959670688361124      0.199612536004054         1
8      2009                      1
0.87403582415134       0.103774779139200          1
 
i wante this like result:

OptimYear            LRPhase
PriorLRPosition                 OptimPosition            LRPosition   
7      2009                      1
0.959670688361124      0.199612536004054         1
8      2009                      1
0.87403582415134       0.103774779139200          1

any ideas,

thank you!!


      
	[[alternative HTML version deleted]]




More information about the R-help mailing list