s-news
[Top] [All Lists]

Function to find closest/matching value

To: <s-news@lists.biostat.wustl.edu>
Subject: Function to find closest/matching value
From: "Lambert.Winnie" <lambert.winifred@ensco.com>
Date: Thu, 9 May 2002 15:57:30 -0400
Thread-index: AcH3k8BaWNKDB8COQBinLCqYHL3Asg==
Thread-topic: Function to find closest/matching value
S-PLUS 6 R2 MSWindows 2000

All,

I have a dataframe with 11,000,000 rows and 2 columns (call it myDF).  I need 
to match a number (myNum) with a value in the second column in order to find 
the value I want in the first column so that myNum == myDF[?,2].  Given that 
the dataframe is so huge, I want to refrain from creating a logical vector and 
subscripting to find the correct row in the data frame.  It takes too long and 
too much memory, and I need to do these matches with lots of numbers.  Is there 
a function that will take as input myNum and match it with a value in myDF[,2] 
and at least give me the row number?  I looked at match and it did not do what 
I wanted, unless I did not enter things correctly.  I prefer not to make myDF 
smaller.

***********************************************************************
Winifred C. Lambert                Senior Scientist/Meteorologist
ENSCO, Inc.
Aerospace Sciences and Engineering Division
1980 N. Atlantic Ave, Suite 230
Cocoa Beach, FL  32931
VOICE: 321.853.8130  FAX: 321.853.8415
lambert.winifred@ensco.com

AMU Quarterly Reports are available online:
http://science.ksc.nasa.gov/amu/home.html
***********************************************************************

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