s-news
[Top] [All Lists]

[S] frequency of data points

To: "'s-news@wubios.wustl.edu'" <s-news@wubios.wustl.edu>
Subject: [S] frequency of data points
From: Kin Cheung <kin_cheung@alkermes.com>
Date: Mon, 26 Apr 1999 10:11:50 -0400
Importance: low
Sender: owner-s-news@wubios.wustl.edu
Dear S+ users,

        I need to create vector in a data frame indicating the
number of frequency data points. For example,

x_c(9,1,2,4,5,9,1,2,6,2,7)
y_c(9,1,2,3,5,9,1,2,4,2,8)
xy_cbind(x,y)

> xy
      x y 
 [1,] 9 9
 [2,] 1 1
 [3,] 2 2
 [4,] 4 3
 [5,] 5 5
 [6,] 9 9
 [7,] 1 1
 [8,] 2 2
 [9,] 6 4
[10,] 2 2
[11,] 7 8


The output that I need would be

> xy
      x y z
 [1,] 9 9 2
 [2,] 1 1 2
 [3,] 2 2 3
 [4,] 4 3 1
 [5,] 5 5 1
 [6,] 9 9 2
 [7,] 1 1 2
 [8,] 2 2 3
 [9,] 6 4 1
[10,] 2 2 3
[11,] 7 8 1

The new vector Z is the number of occurrence of the data points X and Y.

Any help from anyone would be great appreciated.

--cheung







-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>