s-news
[Top] [All Lists]

Re: small question about NA

To: <stephane.g.zebouni@jpmorgan.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: small question about NA
From: "Stewart, William" <william.stewart@rbc.com>
Date: Fri, 19 Aug 2005 10:16:36 -0400
Thread-index: AcWkxxdugyrCL1BIQVyUPvILMFHuSgAAVMTw
Thread-topic: [S] small question about NA
The easiest way I can think of is to use subscripting to exclude NA objects (implicitly treating them as zero in the sum). For example:

test <- c(1,2,3,4,NA,6,7,8,9)

sum(test[!is.na(test)])

-------------------------
William A. Stewart
Manager, Operational Risk
RBC Financial Group
william.stewart@rbc.com
phone: 416-974-3019

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of stephane.g.zebouni@jpmorgan.com
Sent: Friday, August 19, 2005 10:04 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] small question about NA


Hi,

I am using S-plus 6.1. I am making sums of vectors where no value (NA) can occur and I want to consider those values as 0 - is there an easy way to do that?

thanks a lot in advance

Stephane Zebouni
This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein 
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries 
and affiliates.
__________________________________________________________________________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.  

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.

Attachment: Stewart, William.vcf
Description: Stewart, William.vcf

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