I was faced with this recently, too. All I could figure out was to add
entries to the data frame for the zeroes.
In your case, you could build a function to do that, using match() or
some such. Simply create a series for the hours, find out which hours
are missing and assign them a count of zero. Copy over all the other
counts for the hours that exist and run table on the new data frame.
Kim Elmore
----- Original Message -----
From: "Crawford.Winnie" <crawford.winnie@ensco.com>
Date: Thursday, January 29, 2009 3:35 pm
Subject: [S] fill in table names
> All,
>
>
>
> I am running S-PLUS 8 on a Windows XP PC.
>
>
>
> I have data that I want to table to find the number of lightning
> occurrences per hour, even if it is 0. If no lightning occurred
> during a
> certain hour, the hour is not in the data frame. The table() function
> only outputs names for the hours that are in the data frame, e.g.
>
>
>
> >table(dataframe$Hour) yields
>
>
>
> 0 1 2 3 4 6 9 11 12 13 14 15 16 17
> 18 19 20 21 22 23
>
> 152 97 29 15 3 1 1 2 9 15 14 21 31 45
> 60
> 72 98 158 201 225
>
>
>
> This shows there were no lightning strikes at 5:00, 7:00, 8:00 and
> 10:00. How can I get 5, 7, 8, and 10 to show up in the table with
> valuesof 0 associated with them? Thanks for the help.
>
>
>
> Win Crawford
>
>
>
> *****************************************************************
>
> Winifred C. Crawford Staff Scientist/Senior Meteorologist
>
> ENSCO, Inc.
>
> Aerospace Sciences and Engineering Division
>
> 1980 N. Atlantic Ave., Suite 830
>
> Cocoa Beach, FL 32931
>
> VOICE: 321.853.8130 FAX: 321.853.8415
>
> EMAIL: crawford.winnie@ensco.com <mailto:lambert.winnie@ensco.com>
>
>
>
> AMU Quarterly Reports are available online:
>
> http://science.ksc.nasa.gov/amu <http://science.ksc.nasa.gov/amu>
>
> *****************************************************************
>
>
>
> ......................................................................
> The information contained in this email message is intended only
> for the use of the individual(s) to whom it is addressed and may
> contain information that is privileged and sensitive. If you are
> not the intended recipient, or otherwise have received this
> communication in error, please notify the sender immediately by
> email at the above referenced address and note that any further
> dissemination, distribution or copying of this communication is
> strictly prohibited.
>
> The U.S. Export Control Laws regulate the export and re-export of
> technology originating in the United States. This includes the
> electronic transmission of information and software to foreign
> countries and to certain foreign nationals. Recipient agrees to
> abide by these laws and their regulations -- including the U.S.
> Department of Commerce Export Administration Regulations and the
> U.S. Department of State International Traffic in Arms Regulations -
> - and not to transfer, by electronic transmission or otherwise, any
> content derived from this email to either a foreign national or a
> foreign destination in violation of such laws.
|