s-news
[Top] [All Lists]

Re: Split function

To: "Walter R. Paczkowski" <dataanalytics@earthlink.net>
Subject: Re: Split function
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Fri, 15 Apr 2005 15:39:02 +0100 (BST)
Cc: S-News <s-news@lists.biostat.wustl.edu>
In-reply-to: <20050415143136.67B8D1007EF2@mailgate.biostat.wustl.edu>
References: <20050415143136.67B8D1007EF2@mailgate.biostat.wustl.edu>
Try split()ting on the interaction() of the factors you want.

On Fri, 15 Apr 2005, Walter R. Paczkowski wrote:

Good morning,

I'm working with a large set of data from a jewelry market survey. There are over 7000 respondents who answer questions about their gender, future jewelry purchase plans, class of jewelry purchase (bridal, a self purchase or a gift), and the type of style (bracelet, etc.). Each person has an ID. I'd like to create a list of lists that has the ID numbers for each combination of categories: gender, plans, class, style. I could then find the IDs I want by typing, say, z$Male$Yes$Gift$Bracelet, or write a function to call each of these combinations for further data analysis. I want to avoid missing a combination.

SPLIT allows me to easily split the data by gender - no big deal. Just split(x, gender). Splitting each gender by purchase plans is harder, but doable. The result of a little effort is z$Male$Yes, z$Male$No, z$Female$Yes, z$Female$No. Perfect for my purpose. But after that, the task becomes more difficult because of the need to keep track of the levels of each option - or at least the way I was trying to do it. SPLIT can't seem to take a list of groups and then to successively apply them, such as split(x, list(gender, plans, class, style)). Does anyone know of a function that would allow me to do what I want? Or should I forget this and try some other way to easily get the IDs for a bunch of conditions?


--
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

<Prev in Thread] Current Thread [Next in Thread>
  • Split function, Walter R. Paczkowski
    • Re: Split function, Prof Brian Ripley <=