On 3/22/2011 12:47 PM, Phil Spector wrote:
Michael -
I think this does what you want:
*Perfectly*
helm.raw <-
read.table("http://euclid.psych.yorku.ca/datavis/Private/mdshelm.dat",header=TRUE,
row.names=1)
trans =
c('A'='RPur','C'='Red','E'='Yel','G'='Gy1','I'='Gy2','K'='Green','M'='Blue','O'='BlP','Q'='Pur1','S'='Pur2')
cnames = do.call(rbind,strsplit(rownames(helm.raw), ""))
cnames = apply(cnames,2,function(x)trans[x])
uu = unique(as.vector(cnames))
onecol = function(col){
themat = matrix(NA,10,10)
dimnames(themat) = list(uu,uu)
themat[cnames] = col
as.dist(t(themat))
}
result = lapply(as.data.frame(helm.raw),onecol)
Thank you so much for this. Using the onecol function was the main
trick I couldn't see.
-Michael
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
______________________________________________
[email protected] 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.