Dear Marie,
Try this:

combn(v,2,list)

HTH,

Jorge


On Mon, Jun 8, 2009 at 8:56 AM, Marie Sivertsen <mariesiv...@gmail.com>wrote:

> Dear list,
>
> I have a vector of elements which I want to combined each with each, but
> none with itself. For example,
>
> > v <- c("a", "b", "c")
>
> and I need a function 'combine' such that
>
> > combine(v)
> [[1]]
> [1] "a" "b"
>
> [[2]]
> [1] "a" "b"
>
> [[3]]
> [1] "b" "c"
>
> I am not very interested in the orders of the output items for now, and the
> form can be something differs from list, like matrix or data frame. I know
> of 'expand.grid', but it will combine each item with each item including
> itself, so not what I wants.
>
> Could you help me please.  Thank you.
>
> Mvh.,
> Marie
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to