I would like to convert a dataframe to a matrix.
I succeeded using the acast function in the reshape2 package but would like to know how to do it in base R.
# Create data
set.seed(123)
df <- tidyr::expand_grid(x = c(1,2,3), y = c(0,-0.5,-1))
df <- cbind(df, z=rnorm(9))
# Convert dataframe to matrix
example_matrix <- reshape2::acast(df, x~y, value.var="z")
Question
What is the base R alternative for the acast function of reshape2?