I am trying to convert a matrix (myMat
) to raster data (myRas
); however, I am not sure why this rotates all of a sudden. This can be easily fixed by 90-degree rotation using t()
but, I will be grateful if someone explains why this unwanted rotation happens all the time?! and if there is a way to prevent it?
set.seed(23022019)
library(raster)
library(RColorBrewer)
#myMat
myMat<-matrix(runif(3*3), ncol=3)
image((myMat), col=rev(brewer.pal(9,"RdYlBu")))
#myRas
myRas <- raster(myMat)
image((myRas), col=rev(brewer.pal(9,"RdYlBu")))