[R] Variables values on intersected intervals

From: SAULEAU Erik-André <SAULEAUEA_at_ch-mulhouse.fr>
Date: Tue 07 Jun 2005 - 19:40:15 EST


Dear R-list,  

i have a problem, in the framework of simulations, i want to vectorize for earning time: a variable, say X, has values on intervals and an other variable, say Y, has values on other intervals. For example  

Inf     Sup     X
0     2     1
2     4    2
4     6    3
 

and  

Inf     Sup     Y
1     3     1
3     5    2
5     7    3
 

i want to create a matrix like this  

Inf     Sup     X     Y
0     1       1     NA
1     2      1     1
2     3      2     1
3     4      2     2
4     5      3     2
5     6      3     3
6     7      NA     3
 

I get it with loops but it seems to me that it can take a lot of time for a large number of intervals. I cannot get it with some matrix or vector manipulation (quicker than loops). Any solution???  

thank you in advance, with my best regards, erik.  



Erik-André SAULEAU MD, PhD  

SEAIM
Centre hospitalier
87, Avenue d'Altkirch
BP 1070
F-68051 Mulhouse Cédex

Tel: (0033)389646753
Mel: sauleauea@ch-mulhouse.fr <mailto:sauleauea@ch-mulhouse.fr> 
Web: www.ch-mulhouse.fr <http://www.ch-mulhouse.fr/> 

=================================

Registre des Cancers du Haut-Rhin
9, Rue du Dr Mangeney
BP 1370
F-68070 Mulhouse Cédex
Tel: (0033)389646251
Web: www.arer68.org <http://www.arer68.org/>
   

Afin d'eviter toute propagation de virus informatique, et en complement des dispositifs en place, ce message (et ses pieces jointes s'il y en a) a ete automatiquement analyse par un antivirus de messagerie.

        [[alternative HTML version deleted]]



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 Received on Tue Jun 07 19:44:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:26 EST