If I have data that may be modelled as so:
a1 <- c("bob","bill",0.2)
a2 <- c("bob", "bert", 0.1)
a3 <- c("bill", "bert", 0.1)
my.df <- as.data.frame(rbind(a1, a2, a3), stringsAsFactors = FALSE)
colnames(my.df) <- c("name_1", "name_2", "value")
row.names(my.df) <- NULL
my.names <- unique(as.character(c(my.df$name_1, my.df$name_2)))
my.matrix <- matrix(0, nrow = length(my.names), ncol = length(my.names))
row.names(my.matrix) <- my.names
colnames(my.matrix) <- my.names
How may I fill my.matrix using the values from my.df. The first two columns in my.df describe the coordinates of my.matrix to fill?