Message-ID: <559C998F7039D84C9793AE43D9BBE9CE77A0FFAC@kmbx3.utk.tennessee.edu>
Date: 2013-06-20T13:38:17Z
From: Crombie, Burnette N
Subject: help with text patterns in strings
In-Reply-To: <1371674787.56731.YahooMailNeo@web142601.mail.bf1.yahoo.com>
Thanks, Arun. I will study this as soon as possible. I really appreciate your time and R mentoring.
________________________________________
Try this:
res1<-sapply(vec3,function(x) length(vec2New[grep(x,vec2New)]) )
dat1<-data.frame(res1,Name=names(vec3))
dat1$Name<-factor(dat1$Name,levels=c("early","mid","late","wknd"))
with(dat1,tapply(res1,list(Name),FUN=sum))
#early mid late wknd
# 0 1 4 6
#or
sapply(split(res1,names(vec3)),sum)
#early late mid wknd
# 0 4 1 6
A.K.