[R] Newbie: Selecting data

From: Zembower, Kevin <kzembowe_at_jhuccp.org>
Date: Thu 19 Oct 2006 - 20:12:54 GMT

I've been working with R for all of about 8 hours, so anyone with more experience than this should be able to help me. General comments about my methods of work are also welcomed.

I have a table that I've imported thusly:
> w <- read.table("woodford.data", header=T)
> w

       start therms    gas KWHs  elect temp days
1  10-Jun-98      9  16.84  613  63.80   75   40
2  20-Jul-98      6  15.29  721  74.21   76   29
3  18-Aug-98      7  15.73  597  62.22   76   29
4  16-Sep-98     42  35.81  460  43.98   70   33
5 19-Oct-98 105 77.28 314 31.45 57 29 6 17-Nov-98 106 77.01 342 33.86 48 30 <snip>

[This is real data on my house.] 'days' is number of days in bill, 'temp' is average temperature in Fahrenheit. I'd like to see if there is a relationship between the gas burned (therms) and the number of heating degree days.

I compute therms per day and heating degree days like this:
> thermsperday <- w[,2]/w[,7]
> hdd <- (w[,6] -65)*w[,7]

However, I only want the data for the months in which the average temperature is less than 65 (otherwise, it's a cooling degree day). I tried ifelse, but couldn't get it to work. What simple technique am I overlooking?

Thanks so much for your help and suggestions, especially for your patience with a newbie.


Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland 21202

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Oct 20 06:14:21 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 19 Oct 2006 - 22:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.