[18925] in s-news-athena
Re: [S] Frequency counts
daemon@ATHENA.MIT.EDU (Steve Bousquin)
Thu Aug 12 12:11:25 1999
Message-Id: <37B2F076.67103A79@sfwmd.gov>
Date: Thu, 12 Aug 1999 12:04:06 -0400
From: "Steve Bousquin" <sbousqu@sfwmd.gov>
Reply-To: sbousqu@sfwmd.gov
Mime-Version: 1.0
To: "Charles E. (Ted) Wright" <cew@aris.ss.uci.edu>
Cc: "s-news@wubios.wustl.edu" <s-news@wubios.wustl.edu>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Yes, that should have said table(matrix), or table(data),
where the thing in parentheses is the data object.
Charles E. (Ted) Wright wrote:
>
> This summary is somewhat misleading. The matrix() call in the suggested
> summary makes no difference at all: i.e., table(data) will do the same thing
> as table(matrix(data)). The call to matrix turns the vector into an n x 1
> matrix by default, becuase no values have been supplied for the arguments
> nrow= or ncol=, but that transformation has absolutely no effect on the
> table call.
>
> Because the vector data contains character data and not a category (or
> factor in older versions of S), the explicitly correct answer would be
>
> table(category(data)) or equivalently table(factor(data))
>
> However, because table() examines its arguments and calls category() for
> those that are not already categorical, the explicit call to category() or
> factor() is unnecessary and, thus, simply
>
> table(data)
>
> works fine. Again, however, the matrix() call has no logical or actual
> advantage here.
>
> Ted Wright
>
> ==============================================================================
> | Charles E. (Ted) Wright: Associate Professor |
> | Interim Department Chair, Cognitive Sciences |
> | Office: Room 3119 USMail: Dept. of Cognitive Sciences |
> | Social Science Plaza Social Sciences Plaza, Rm. 3151 |
> | (949) 824-7589 UC-Irvine |
> | Fax: (949) 856-2590 Irvine, CA 92697-5100 |
> | email: cewright@uci.edu web: www.socsi.uci.edu/cogsci |
> ==============================================================================
>
> On Thu, 12 Aug 1999, Steve Bousquin wrote:
>
> >
> > Thanks for the large response. Several people suggested
> > that this could not be done without a custom function, and a
> > number of people sent interesting functions. I can
> > summarize if anyone is interested. However,
> >
> >
> > table(matrix(data))
> >
> >
> > worked fine for this purpose.
> >
> >
> >
> >
> > Steve Bousquin wrote:
> > >
> > > Is there an S-Plus function that will count the number of
> > > unique values or text items in a column, and give the number
> > > of occurrances of each alongside the value
> > > or text ?
> > >
> > > E.g., for a column that reads:
> > >
> > > At
> > > B
> > > A
> > > A
> > > B
> > > A
> > > A
> > > C
> > >
> > > I want output that reads:
> > >
> > > A 3
> > > At 1
> > > B 2
> > > C 1
> > >
> > > Thanks!
> > >
> > > =======================================
> > > Steve Bousquin
> > >
> > > Kissimmee River Restoration Division
> > > South Florida Water Management District
> > > West Palm Beach, FL
> > >
> > > sbousqu@sfwmd.gov
> > > =======================================
> > > -----------------------------------------------------------------------
> > > This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> > > send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> > > message: unsubscribe s-news
> >
> > --
> > =======================================
> > Steve Bousquin
> >
> > Kissimmee River Restoration Division
> > South Florida Water Management District
> > West Palm Beach, FL
> >
> > sbousqu@sfwmd.gov
> > =======================================
> > -----------------------------------------------------------------------
> > This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> > send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> > message: unsubscribe s-news
> >
>
> -----------------------------------------------------------------------
> This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> message: unsubscribe s-news
--
=======================================
Steve Bousquin
Kissimmee River Restoration Division
South Florida Water Management District
West Palm Beach, FL
sbousqu@sfwmd.gov
=======================================
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news