Skip to content

comparing a vactor of values in IF statement.

3 messages · Jagarlamudi, Choudary, Gabor Grothendieck, Ravi Varadhan

#
Try

  V <- ifelse(V > 0.5, 1-V, V)

or 

  V <- pmin(V, 1-V)
On 5/20/05, Jagarlamudi, Choudary <choudary.jagar at swosu.edu> wrote:
#
Both

V[V > 0.5] <- 1 - V[V > 0.5]

and 

ifelse(V>0.5, 1-V,V)

should do it.

Ravi.

--------------------------------------------------------------------------
Ravi Varadhan, Ph.D.
Assistant Professor,  The Center on Aging and Health
Division of Geriatric Medicine and Gerontology
Johns Hopkins University
Ph: (410) 502-2619
Fax: (410) 614-9625
Email:  rvaradhan at jhmi.edu
--------------------------------------------------------------------------