[datatable-help] Extracting specific values from a matrix
Mike.Gahan
michael.gahan at gmail.com
Thu Aug 21 19:19:06 CEST 2014
This is one method that might work.
#Melt matrix and then convert to data.table object
yourmatrix <- melt(yourmatrix)[melt(upper.tri(yourmatrix))$value,]
names(yourmatrix) <- c("v1", "v2", "value")
yourmatrix <- data.table(yourmatrix)
#Setkeys and reference quickly
setkey(yourmatrix,v1,v2)
yourmatrix[J("B","C")]
--
View this message in context: http://r.789695.n4.nabble.com/Extracting-specific-values-from-a-matrix-tp4695768p4695818.html
Sent from the datatable-help mailing list archive at Nabble.com.
More information about the datatable-help
mailing list