Re: [R] Is there an equivalent * operator?

From: john seers (IFR) <john.seers_at_bbsrc.ac.uk>
Date: Thu, 24 Jul 2008 11:47:41 +0100

 

Something like this might do what you want:

dates<-paste(c("2008"), c("Jan", "Feb", "Sep", "Sep", "Dec"), 1:3, sep="")
temp<-rnorm(length(dates))*30
data1<-data.frame(Dates=dates, Temp=temp)

data.s1<-data1[grep("Sep", data1[["Dates"]]),]

> data.s1

     Dates Temp
3 2008Sep3 22.263627
4 2008Sep1 9.854643  

Regards

JS

---

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org]
On Behalf Of Williams, Robin
Sent: 24 July 2008 11:31
To: r-help_at_r-project.org
Subject: [R] Is there an equivalent * operator?

Hi all,
Is there an equivalent to the general * operator in R, where * can
represent any character? 
  I have a dataset, one column being date, date ranging between
April-September, 97-06. I would like to be able to acquire the data for
a specific month, say September, so that I can take average temperatures
for the month, etc. I thought I would be able to do something like
data.s1 <- subset(data,date=="**-Sep-**")
data.s1
but when I do
data.s1
I get "0 rows or 0-length row.names". 
  Any idea of a simple way I can perform this task? 
All dates are in the form xx-xxx-xx, EG 30-Sep-06. 
Thanks for any assistance.  
 

Robin Williams
Met Office summer intern - Health Forecasting
robin.williams_at_metoffice.gov.uk 

 

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org 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.

______________________________________________
R-help_at_r-project.org 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 Thu 24 Jul 2008 - 10:53:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jul 2008 - 11:32:37 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.

list of date sections of archive