Hi Arun

I have two questions always about the question of symplify a dataframe

I would like
1)  to transform the vector x1 into the vector y1
x1 <- c(1,1,1,-1000,         1,-1000,          1,1,1,1,1,1,-1000)
y1 <- c(1,1,1,1,                    2,2, 3,3,3,3,3,3,3)


2) to transform the vectors Debut and Fin by taking into account INDX 
into the two vectors Deb and Fin
Debut <- c (
"24/01/1995", "01/05/1997" ,"31/12/1997", "02/02/1995" ,"28/02/1995" 
,"01/03/1995",
"13/03/1995", "01/01/1996", "31/01/1996", "24/01/1995", "01/07/1995" 
,"01/09/1995",
  "01/07/1997", "01/01/1998", "01/08/1998", "01/01/2000", 
"17/01/2000","29/02/2000")

Fin <- c (
"30/04/1997", "30/12/1997" ,"31/12/1997", "27/02/1995", "28/02/1995", 
"12/03/1995",
"30/06/1995", "30/01/1996", "31/01/1996", "30/06/1995", "31/08/1995", 
"30/06/1997",
"31/12/1997", "31/07/1998", "31/12/1999", "16/01/2000", "28/02/2000", 
"29/02/2000")

INDX <- c(6,6,6,                    11,11,11, 4,        5,5)


Deb  <- c("*24/01/1995*",     "*02/02/1995*",     "*13/03/1995*",   
"*01/01/1996*")
Fi n  <-  c("*31/12/1997*", "*12/03/1995*",     "*30/06/1995*",  
"*31/01/1996*")


      Debut        Fin INDX
*24/01/1995* 30/04/1997    6
01/05/1997 30/12/1997    6
31/12/1997 *31/12/1997*    6
*02/02/1995* 27/02/1995   11
28/02/1995 28/02/1995   11
01/03/1995 *12/03/1995*   11
*13/03/1995* *30/06/1995*    4
*01/01/1996* 30/01/1996    5
31/01/1996 *31/01/1996*    5
................

Thanks for your help

-- 
Michel ARNAUD
Chargé de mission auprès du DRH
DGDRD-Drh - TA 174/04
Av Agropolis 34398 Montpellier cedex 5
tel : 04.67.61.75.38
fax : 04.67.61.57.87
port: 06.47.43.55.31


        [[alternative HTML version deleted]]

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

Reply via email to