I have a data table, and I try Reshaping it but it doesn\'t work, how do I do this:
I have a data table:
Name | Value
-------------
Bob | 8,9,10
-------
res <- read.table(text="Name | Value
Bob | 8,9,10
Mike | 2,3,4
Sandr| 5,6,7", header=TRUE, sep="|")
dres <- data.frame(Value= unlist( strsplit(as.character(res$Value), ",") )
, Name=rep(res$Name, each=3))
dres <- dres[order(as.numeric(as.character(dres$Value))), ]
dres
outer(sort(dres$Value), sort(dres$Value), FUN=function(x,y) dres[x, "Name"] == dres[y,"Name"] )
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
[2,] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
[3,] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
[4,] FALSE FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE
[5,] FALSE FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE
[6,] FALSE FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE
[7,] FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
[8,] FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
[9,] FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE