s-news
[Top] [All Lists]

Simple Logic If, then replacement question

To: s-news@wubios.wustl.edu
Subject: Simple Logic If, then replacement question
From: Joseph E Wolfe <Joseph_E_Wolfe@notes.ntrs.com>
Date: Thu, 21 Apr 2005 09:55:32 -0500
Greetings,

Thanks to everyone for your last reply helping me with my simple data
manipulation questions.  There were many great suggestions and I am going
to attend a course on S-Plus for SAS users.  I have another issue that I am
working on which I think you will find most trivial.  I wish to replace the
contents of one element of a dataframe if a certain condition is met.
Specifically, I would like to replace the element of a filled called Alpha
with a 0 if the element of another field, "Missing"  is not null.

I was working with the following statement.  The dataframe I was working
with was called test.  When the Missing field is not null I would like to
replace the element of Alpha with a numeric value of 0.  I am working with
Windows XP and S-Plus 6.2


if (test$Missing!="NA") test$Alpha<-0

I get the following message, basically it is just running on the very first
row and not on the remainder of the dataframe.

Warning messages:
  Condition has 55522 elements: only the first used in: if(test$gt5 !=
   "NA")


Thanks in advance for you suggestions and time


Joseph Wolfe


<Prev in Thread] Current Thread [Next in Thread>
  • Simple Logic If, then replacement question, Joseph E Wolfe <=