s-news
[Top] [All Lists]

Re: Creating more than two level factor variables

To: Carlos Davidson <cdavidson@csus.edu>
Subject: Re: Creating more than two level factor variables
From: Sundar Dorai-Raj <sundar.dorai-raj@PDF.COM>
Date: Tue, 31 Aug 2004 15:50:17 -0700
Cc: s-news@wubios.wustl.edu
In-reply-to: <5.2.0.9.0.20040831153447.011b3f88@pop3.saclink.csus.edu>
Organization: PDF Solutions, Inc.
References: <5.2.0.9.0.20040831153447.011b3f88@pop3.saclink.csus.edu>
Reply-to: sundar.dorai-raj@PDF.COM
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)


Carlos Davidson wrote:

Splus-list,

I would like to create a four level factor variable from two binary factor variables. So for a dataset with 1000 plus sites I have information on two different categorical binary variables (fish present - yes/no, and lake depth deep/shallow) and I would like to create a single factor variable with the factors "fishshallow","fishdeep", "nofishdeep","nofishshallow". Any suggestions of code to do this - call my two binary variales fish ( values "Y" and "N") and depth (values "Deep","Shallow")?

Thank you!

Carlos


How about:

fish <- ifelse(fish == "Y", "fish", "nofish")
fish.depth <- factor(paste(fish, depth, sep = ""))


--sundar



<Prev in Thread] Current Thread [Next in Thread>