s-news
[Top] [All Lists]

Re: Data manipulation

To: Don MacQueen <macq@llnl.gov>
Subject: Re: Data manipulation
From: "David L Lorenz" <lorenz@usgs.gov>
Date: Fri, 21 Jun 2002 07:35:56 -0500
Cc: rollins8@msu.edu, s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
Scott,
  The function tapply will do what you want.  Try this:
out.mat <- tapply(df[["ra"]], df[c("site","species")], FUN=sum)
  You will need to replace the NAs in out.mat with 0s.
  What kind of distance function do you plan to use?  Many of those used by
ecologists are not directly coded in S-PLUS.
Dave


                                                                                
                                                       
                    Don MacQueen                                                
                                                       
                    <macq@llnl.gov>                   To:     "Scott Rollins" 
<rollins8@msu.edu>, <s-news@lists.biostat.wustl.edu>     
                    Sent by:                          cc:                       
                                                       
                    s-news-owner@lists.biostat        Subject:     Re: [S] Data 
manipulation                                           
                    .wustl.edu                                                  
                                                       
                                                                                
                                                       
                                                                                
                                                       
                    06/20/2002 10:00 AM                                         
                                                       
                                                                                
                                                       
                                                                                
                                                       



Why don't you give a short example of the data manipulation you need
to perform. That is, a few rows of a data frame and the matrix it
would become.

You mention a "crosstab" query. So try help(crosstabs) in Splus, and
that will cross-reference "table" and "tabulate".

-Don

At 10:42 AM -0400 6/19/02, Scott Rollins wrote:
>I'm in need of data manipulation help.  This is the first time I've
>tried to use S-Plus (version 4.5 running in Windows ME) for cluster
>analysis.  I have a dataframe containing 3 columns: site, species, ra
>(relative abundance).  I'd like to cluster groups of sites based on
>their species composition, but I'm having trouble converting the data
>into the proper matrix format.  Not all sites contain the same species,
>nor equal numbers of species.  That is, the ra vector contains no zero
>values, but the site by species matrix will contain many zeros.  I'm
>convinced that I can do this in S-Plus and that I don't have to export
>the data to MS Access and run a crosstab query to create the matrix!
>Can anyone help me?
>
>Thanks,
>Scott
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Scott L. Rollins
>Research Assistant
>Algal Ecology Lab
>Department of Zoology
>203 Natural Science Building
>Michigan State University
>East Lansing, Michigan 48824-1115
>Phone: 517-432-8084
>FAX: 517-432-2789
>e-mail: rollins8@msu.edu
>
>
>--------------------------------------------------------------------
>This message was distributed by s-news@lists.biostat.wustl.edu.  To
>unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
>the BODY of the message:  unsubscribe s-news


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
--------------------------------------

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news





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