[S] Creating first difference object

Erin Hodgess (hodgess@uhdux2.dt.uh.edu)
Fri, 06 Mar 1998 16:17:59 -0600


Dear Thomas:

You'll like this solution:

> B <- diff(A)

The diff command takes the differences of the object.
The default diff is 1, so you're all set!

Hope this helps!

Sincerely,
Erin Hodgess
Assistant Professor
Dept. of Computer and Mathematical Sciences
University of Houston -- Downtown
e-mail: hodgess@uhdux2.dt.uh.edu

From: "Thomas J. Downing" <t_downing@yahoo.com>
Subject: [S] Creating first difference object

Dear List:

I am a relatively new user to S-PLUS and there is probably a
simple answer to this, but my current problem is: Given an n x k
matrix A, I would like to create an (n-1) x k matrix B where each
element B n,k = A n+1,k - A n,k (see below)

Given data frame A : desired object B :

100 100 100 100
103 102 98 103 3 2 -2 3
100 104 95 100 -3 2 -3 -3
100 106 96 102 0 2 1 2
97 109 96 102 -3 3 0 0
99 111 96 101 2 2 0 -1
98 113 93 98 -1 2 -3 -3
98 111 90 96 0 -2 -3 -2

Any help with this problem is greatly appreciated.
==
Thomas J. Downing
Research Assistant
Quantitative Research
Value Line, Inc.

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

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

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