I was having some trouble lately trying to replace specific values in a data frame or matrix by using a lookup-table.
So this represents the original.data to be modi
you can try :
# x the original.data (a matrix) # y the lookup.table x2 <- y[match(x, y[,1]),2] dim(x2) <- dim(x) table(x, x2) x2 x 1 2 3 4 5 255 1 13 0 0 0 0 0 2 0 22 0 0 0 0 3 0 0 29 0 0 0 4 0 0 0 8 0 0 5 0 0 0 0 11 0 6 0 0 4 0 0 0 7 0 4 0 0 0 0 8 0 5 0 0 0 0 255 0 0 0 0 0 100