For instance given:
dim1 <- c("P","PO","C","T")
dim2 <- c("LL","RR","R","Y")
dim3 <- c("Jerry1", "Jerry2", "Jerry3")
Q <- array(1:48, c(4, 4, 3), dimnames = list(dim1, dim2, dim3))
I want to reference within this array, the matrix that has the max dim3 value at the (3rd row, 4th column) location.
Upon identifying that matrix, I want to return the column name which has the maximum value within the matrix’s (3rd Row, 1st Column) to (3rd Row, 3rd Column) range.
So what I’d hope to happen is that Jerry3 gets referenced because the number 47 is stored in its 3rd row, 4th column, and then within Jerry3, I would want the maximum number in row 3 to get referenced which would be 43, and ultimately, what I need returned (the only value I need) is then the column name which would be "R".
That’s what I need to know how to do, obtain get that "R" and assign it to a variable, i.e. "column_ref", such that column_ref <- "R".
This should do it – if I understand correctly:
Some explanation:
…and then
namesreturns the name of the index (“R”).