[R] If else in R code

From: Andrew McFadden <Andrew.McFadden_at_maf.govt.nz>
Date: Fri, 8 Feb 2008 14:23:11 +1300


Hi There

I am a new user of "R" and having a few problems

a<-c("2001-02-1","NA","NA")
a<-as.Date(a,format = "%Y-%m-%d")

b<-c("2001-03-1","2001-03-2","2001-03-3") b<-as.Date(b,format = "%Y-%m-%d")

c<-data.frame(a,b)

I would like to write an if statement where if "a" is not null return "a", if "a" is null (NA) return "b" less two days. Could someone help?.

Andrew

########################################################################
This email message and any attachment(s) is intended solely for the addressee(s) named above. The information it contains is confidential and may be legally privileged. Unauthorised use of the message, or the information it contains, may be unlawful. If you have received this message by mistake please call the sender immediately on 64 4 8940100 or notify us by return email and erase the original message and attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for changes made to this email or to any attachments after transmission from the office.
########################################################################

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 08 Feb 2008 - 01:30:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Feb 2008 - 06:30:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive