s-news
[Top] [All Lists]

Assigning empty subsets of data.frames

To: s-news@wubios.wustl.edu
Subject: Assigning empty subsets of data.frames
From: gerald.jean@dgag.ca
Date: Tue, 20 Feb 2007 14:36:42 -0500
Hello,

in one of my functions I have statements like this one:

out[mod1.no.mod2, c("Freq.Diff", "Freq.t")] <- ttt.1[mod1.no.mod2,
                                                       c("Diff.",
"t.value")]

mod1.no.mod2 is a character variable and is computed.  Occasionnally
mod1.no.mod2 is empty, i.e. it is equal to «character(0)».  In these
circumstances S+ complains and the function aborts returning the error:

Problem in out[mod1.no.mod2, c("Freq.Diff", "Freq.t")]  <..: 0 rows in
value to replace 147 rows

The error message here is not quite correct since the 0 rows in value are
trying to replace 0 rows in "out"!

Is there ways around this without putting an if statement to check if
mod1.no.mod2 is empty or not, changing the mode of mod1.no.mod2 maybe?  I'd
rather avoid the if statement since I have several similar assignements in
my function.

Thanks in advance,

Gérald Jean
Conseiller senior en statistiques, Actuariat
télephone            : (418) 835-4900 poste (7639)
télecopieur          : (418) 835-6657
courrier électronique: gerald.jean@dgag.ca

"In God we trust, all others must bring data"  W. Edwards Deming

Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés 
uniquement aux personnes identifiées et peuvent contenir des informations
privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu 
ce message par erreur, veuillez le détruire.

This communication (and/or the attachments) is intended for named recipients 
only and may contain privileged or confidential information which is not
to be disclosed. If you received this communication by mistake please destroy 
all copies.



<Prev in Thread] Current Thread [Next in Thread>
  • Assigning empty subsets of data.frames, gerald . jean <=