Re: [R] help with text patterns in strings

2013-06-20 Thread Crombie, Burnette N
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(

Re: [R] help with text patterns in strings

2013-06-19 Thread arun
, Burnette N" To: arun Cc: Sent: Wednesday, June 19, 2013 3:55 PM Subject: RE: [R] help with text patterns in strings Arun, let me know if I should post this email separately, but it involves the script from our previous conversation.  I've been messing around as I think of potential sc

Re: [R] help with text patterns in strings

2013-06-17 Thread arun
  F Sa # 2  0  0  1  1  3  4 #Or Using Bills' solution: dayNames[pmatch(vec2New,dayNames,duplicates.ok=TRUE)] # [1] "Friday"    "Wednesday" "Friday"    "Saturday"  "Sunday"    "Saturday"  #[7] "Saturday"  "Sunday" 

Re: [R] help with text patterns in strings

2013-06-17 Thread William Dunlap
Friday" "Tuesday" "Thursday" NA NA "T" could be either "Tuesday" or "Thursday" so it is mapped to NA, as are entries like "Lunes" that do not match at all. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -O

Re: [R] help with text patterns in strings

2013-06-17 Thread arun
    "Wednesday" "Friday"    "Saturday"  "Sunday"    "Saturday"  #[7] "Sat"   "Sun"   "Th"    "F"     "Sa"      sapply(vec1,function(x) length(vec2[grep(x,vec2)]) ) #Su  M Tu  W Th  F Sa

[R] help with text patterns in strings

2013-06-17 Thread bcrombie
Let’s say I have a data set that includes a column of answers to a question “What days of the week are you most likely to eat steak?”. The answers provided are [1] “Friday”, [2] “Wednesday”, [3] “Friday, Saturday, Sunday", [4] "Saturday”, [5] “Sat, Sun”, [6] “Th, F, Sa” How can I tell R to count “