I'm not sure exactly what this would be called, so I'm struggling to search for it. Sorry if this is a repeated question, that would be why.
I have a data 43x17 data matrix,lets call it A, with four levels in the "site" column. I also have another 4x3 matrix containing coordinates for each site, lets call it B. I'd like to create a column in A where each site is assigned the coordinate listed in B.
Using the data below as an example, I'd like to make a new column in A and populate it with values from Coordinate1 (in B) with the associated "Site" value.
A <- matrix(c(1:4), nrow = 12, ncol = 3, byrow = TRUE,
dimnames = list(c(1:12),
c("Site", "D.2", "D.3")))
A
B<- matrix(c(1:4), nrow = 4, ncol = 3, byrow = TRUE,
dimnames = list(c(1:4),
c("Site", "Coordinate1", "Coordinate2")))
B
I'm sure this is simple, but I'm blanking on what to call this and have apparently forgotten how to do it!