I am trying to create a new variable which uses the suburb names if HR and HRRES are the same but which uses HRRES if they are different. Any assistance would be appreciated as my brain has just packed up. I'm not sure I can teach myself anymore new tricks this afternoon. HR HRRES SUBURB What I am trying to get 954 Wheatbelt Great Southern ALBANY Great Southern 3177 Wheatbelt Wheatbelt ARDATH Ardath 3564 Wheatbelt Metro ARMADALE Metro 3825 Wheatbelt Wheatbelt ARTHUR RIVER Arthur River 5049 Wheatbelt South West AUSTRALIND SouthWest 5445 Wheatbelt Wheatbelt BABAKIN Babakin 5769 Wheatbelt Wheatbelt BADGINGARRA Bagingarra 6093 Wheatbelt Wheatbelt BAKERS HILL Bakers Hill 7065 Wheatbelt Wheatbelt BALLIDU Ballidu 9396 Wheatbelt Metro BAYSWATER Metro 9657 Wheatbelt Wheatbelt BEACON Beacon 12492 Wheatbelt Wheatbelt BENCUBBIN Bencubbin 13122 Metro Metro BENTLEY Bentley 13788 Metro Metro BEVERLEY Beverley 14436 Metro Metro BINDI BINDI Bindi Bindi 14517 Metro Metro BINDOON Bindoon 16218 Metro Wheatbelt BODALLIN Wheatbelt _________________________________________________ Tom Mulholland Senior Policy Officer WA Country Health Service 189 Royal St, East Perth, WA, 6004 Tel: (08) 9222 4062 e-mail: Tom.Mulholland at health.wa.gov.au The contents of this e-mail transmission are confidential an...{{dropped}}
Thank you. When I received the reply it dawned on me why my attempts had been unsuccessful. HR, HRRES and SUBURB are all factors. It's time to go home I was at this solution an hour ago and somehow missed it. I've now got it working. -----Original Message----- From: Petr Pikal [mailto:petr.pikal@precheza.cz] Sent: Thursday, 17 July 2003 4:27 PM To: Mulholland, Tom Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Recode from 2 variables Hi On 17 Jul 2003 at 16:17, Mulholland, Tom wrote:> I am trying to create a new variable which uses the suburb names if HR > and HRRES are the same but which uses HRRES if they are different. Any > assistance would be appreciated as my brain has just packed up. I'm > not sure I can teach myself anymore new tricks this afternoon.Something like ifelse(HR==HRRES,suburb,HRRES) should help [[alternative HTML version deleted]]