Re: [R] esercizio

From: Mose Andre <mose.andre_at_gmail.com>
Date: Mon, 03 Mar 2008 10:32:44 -0800

Hey Flo,

I'm not entirely sure what you're problem is -- due to the language thing, probably -- but I think you want a function that will give you (or computes in an intermediate step) the "edit distance" between strings. There is the "sdists" function in the cba package that might help (it can give you the pairwise distances between a bunch of strings easily), or you can use the "agrep" function to find approximate matches:

>max.edits <- list(all=1, substitutions=1, insertions=0, deletions=0)
>words <- c("casa", "cosa", "rosa")
>agrep(pattern="casa", x=words, max.distance=max.edits)
[1] 1 2

i.e. "casa" matches (within 1 letter substitution) the 1st and 2nd elements of the words vector. "casa" is an approximate match to "casa" and to "cosa" but not "rosa" because that's two substitutions and we chose a max of one.

• Mose

On Mon, Mar 3, 2008 at 8:47 AM, Flo <floah_at_yahoo.it> wrote:

> Ciao a tutti!
> ho un problema con un esercizio in R.
>
> In una lista devo trovare tutte le parole che si differenziano per una
> lettera da un'altra parola.
> Esempio: per "casa": cosa, rosa...
>
> C'è una formula generale da applicare a tutte le parole?
> Grazie dell'aiuto, Flo
>
>
> ---------------------------------
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[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. Received on Mon 03 Mar 2008 - 18:41:01 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 Mon 03 Mar 2008 - 19:30:25 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.