[R] mapping one redundant index to another redundant index

Gabor Grothendieck ggrothendieck at gmail.com
Sat Jun 28 17:08:59 CEST 2008


merge(tmp1, tmp2) gives the basic data and you can put it
in the form requested using:

Tmp1 <- data.frame(x = tmp1)
Tmp2 <- data.frame(x = tmp2)

M <- merge(Tmp1, Tmp2)
data.frame(tmp1 = M$x, tmp2 = M$x)

or using Tmp1 and Tmp2 from above:

library(sqldf)
sqldf("select x tmp1, x tmp2 from Tmp1 natural join Tmp2")

See sqldf home page at:
http://sqldf.googlecode.com


On Sat, Jun 28, 2008 at 7:38 AM, John Lande <john.lande77 at gmail.com> wrote:
> Dear R users,
>
> I have a simple problem I cannot solve, but I sure you can help.
>
> I have two vector, let say
>
>> tmp1 <- c("a", "a", "b", "c")
>> tmp2 <- c("a", "a", "b", "c", "c", "d")
>
> and I want to create a matrix of two column for which I have all the
> combinations of the same character, let say like this
>
>> tmp3
>     tmp1 tmp2
> [1,] "a"  "a"
> [2,] "a"  "a"
> [3,] "a"  "a"
> [4,] "a"  "a"
> [5,] "b"  "b"
> [6,] "c"  "c"
> [7,] "c"  "c"
>
>
> how can I perform this task?
>
>
> thank you!
>
>        [[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.
>



More information about the R-help mailing list