Andrew McFadden
2009-Apr-14 03:24 UTC
[R] Subset function: selecting variables within a factor
Hi all I know this must be an easy one so sorry for the trouble. I would like to select a list of variables within a factor The following example is given in help for subset: subset(airquality, Temp > 80 select = c(Ozone, Temp)) So how do I select all temperatures of 90 and 80 ie Temp = c(80,90) I would appreciate your help. Kind regards andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and Forestry Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St Upper Hutt ######################################################################## 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]]
Thomas Lumley
2009-Apr-14 03:28 UTC
[R] Subset function: selecting variables within a factor
On Tue, 14 Apr 2009, Andrew McFadden wrote:> Hi all > > I know this must be an easy one so sorry for the trouble. I would like > to select a list of variables within a factor > The following example is given in help for subset: > > subset(airquality, Temp > 80 select = c(Ozone, Temp)) > > So how do I select all temperatures of 90 and 80 ie Temp = c(80,90)subset(airquality, Temp %in% c(80,90)) -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
Andrew McFadden
2009-Apr-14 04:08 UTC
[R] [Requires Classification] Re: Subset function: selecting variables within a factor
Hey Thomas Thanks mate I knew there had to be an easy answer. Thanks for coming to my rescue. Regards Andrew McFadden MVS BVSc | Incursion Investigator (animals), Investigation and Diagnostic Centre | Biosecurity New Zealand Ministry of Agriculture and Forestry | 66 Ward St, Wallaceville | PO Box 40 742 | Upper Hutt | New Zealand Telephone: 64-4-894 5611 | Facsimile: 64-4-894 4973| Mobile: 027-733-1791 | Web: www.maf.govt.nz -----Original Message----- From: Thomas Lumley [mailto:tlumley at u.washington.edu] Sent: Tuesday, 14 April 2009 3:29 p.m. To: Andrew McFadden Cc: r-help at r-project.org Subject: [Requires Classification] Re: [R] Subset function: selecting variables within a factor On Tue, 14 Apr 2009, Andrew McFadden wrote:> Hi all > > I know this must be an easy one so sorry for the trouble. I would like> to select a list of variables within a factor The following example is> given in help for subset: > > subset(airquality, Temp > 80 select = c(Ozone, Temp)) > > So how do I select all temperatures of 90 and 80 ie Temp = c(80,90)subset(airquality, Temp %in% c(80,90)) -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle ######################################################################## 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. ########################################################################