I have a data frame and I would like to create a table of all cell values, along with their row and column names. For example,
a <- c(1:4)
df <- matrix(a, nrow = 2, ncol = 2, byrow = T)
rownames(df) <- c("Paul", "Matt")
colnames(df) <- c("Beach", "Hike")
df <- as.data.frame(df)
df
I would like the output to be a data frame with the following columns:
Paul | 1 | Beach
Paul | 2 | Hike
Matt | 3 | Beach
Matt | 4 | Hike
I need to sort the numeric value for all combinations of rows and colums for a very large data set so if anyone could help me out that'd awesome :)
Thanks!