[R] filtering number of values in a data frame

René Schönemann rene.schoenemann at tu-berlin.de
Thu Jun 18 14:45:39 CEST 2009


Dear list,

given is the following data frame df():

        Number           Place               Start                 End
1 218024740787 HHO     5   263 2008-01-02 00:21:14 2008-01-03 15:25:16
2 218024740787 HHO     5   263 2008-01-02 00:21:14 2008-01-02 00:21:14
3 318039091794 HHO     5   263 2008-01-02 00:21:14 2008-01-02 13:22:54
4 318039091794 HHO     5   263 2008-01-02 00:21:14 2008-01-02 00:21:14
5 318039379900 HHO     1   104 2008-01-02 06:45:01 2008-01-02 09:15:23

Now, I want to count the number of equal values of column "Start" but I also
want the other columns to be preserved.

Using:

	rle(as.character(df$Start)) -> m
	n <- data.frame(m$values, m$lengths)

produces a list of items according to their frequency of the Start point:

	             m.values m.lengths
	1 2008-01-02 00:21:14         4
	2 2008-01-02 06:45:01         1


I want now also other columns to be in this new data frame. It should look
like that:

	         Number           Place           m.values  m.lengths
	1 218024740787 HHO     5   263 2008-01-02 00:21:14         4
	2 318039379900 HHO     1   104 2008-01-02 06:45:01         1


Does anybody can help me with this?

Thanking you in advance!

René Schönemann

-- 
______________________________________________________

Technische Universität Berlin
Institut für Land- und Seeverkehr
Fachgebiet Schienenfahrwege und Bahnbetrieb 
Prof. Dr.-Ing. habil. Jürgen Siegmann

Post        Sekretariat SG 18
            Salzufer 17-19
            D-10587 Berlin

Telefon     +49 (0)30 314 - 23 314 

Internet    http://www.railways.tu-berlin.de
______________________________________________________

Dipl.-Verk.wirtsch. René Schönemann
- Wissenschaftlicher Mitarbeiter -

Telefon     +49 (0)30 314 - 22 710
Telefax     +49 (0)30 314 - 25 530

E-Mail      RSchoenemann at railways.tu-berlin.de
______________________________________________________

Technische Universität Berlin
Körperschaft öffentlichen Rechts

Präsident   Prof. Dr. Kurt Kutzler 




More information about the R-help mailing list