[R] greatest common substring

2006-11-14 Thread Jonne Zutt
Dear R-members, Suppose I have a vector with the following strings: V = c(Welfare_Group_1024, Welfare_Group_1536, Welfare_Group_160) I want to 'automatically generate a nice y-axis label for this data. A good candidate is something close to Welfare Group. Is there an easy way to

Re: [R] greatest common substring

2006-11-14 Thread Gabor Grothendieck
Try: V1 - c(Welfare_Group_1024, Welfare_Group_1536, Welfare_Group_160) V2 - c(xxxWelfare_Group_1024, yWelfare_Group_1536, zWelfare_Group_160) lcs - function(ff) { L - ff[1]; for(f in ff) L - lcs2(f,L); L } lcs(V1) lcs(V2) where lcs2 was posted here: