[R] fill-in a table of pairs
jim holtman
jholtman at gmail.com
Wed Feb 7 20:04:09 CET 2007
How about this:
> x
1 2
1 joe 0.45
2 mike 0.34
3 jim 0.25
> combine <- combn(3, 2)
> combine
[,1] [,2] [,3]
[1,] 1 1 2
[2,] 2 3 3
> ans <- cbind(x[combine[1,],2], x[combine[2,], 2])
> rownames(ans) <- paste(x[combine[1,], 1], x[combine[2,], 1], sep='.')
> ans
[,1] [,2]
joe.mike 0.45 0.34
joe.jim 0.45 0.25
mike.jim 0.34 0.25
>
>
On 2/7/07, Serguei Kaniovski <Serguei.Kaniovski at wifo.ac.at> wrote:
>
> Hallo,
>
> I have a table of names and values:
> joe 0.45
> mike 0.34
> jim 0.25
>
> I would like to fill-in a table of all pairs of names (which I aleady have)
> joe.mike NA NA
> joe.jim NA NA
> mike.jim NA NA
>
> with the values from the first table in the order of the pairs. The outcome
> looks like
> joe.mike 0.45 0.34
> joe.jim 0.45 0.25
> mike.jim 0.34 0.25
>
> Thanks a lot,
> Serguei
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list