Plot raster by nrow and ncol (dimensions) in R

I'm having trouble finding documentation on how to change the x and y axes from coordinates (extent) to nrow and ncol (dimension). When I plot a raster:

r1 <- raster(ncol=10, nrow=10, crs="EPSG:4326")
values(r1) <- sample(80:100, 100, replace=TRUE)
plot(r1)

enter image description here

The x and y axes are pulling from crs. I want x and y to be based on the number of rows and columns:

enter image description here

Seems like there should be an obvious solution and I'm just not finding it. I checked docs on plot(), led me to graphical parameters, no luck. I tried forcing the axes with ymn, ymx, xmn, xmx. I thought to remove the crs, but that's just making things messy. Any other ideas?


I think you had it with setting the values for the extent of the raster. The number columns and rows sets the resolution in raster(), but not the extent. I believe that by default the extent in raster() is the extent of the Earth so -90, +90 for latitude and -180, +180 for longitude. Here's an example:

library(raster)
set.seed(42)

r1 <- raster(ncol=10, nrow=10, crs="EPSG:4326")
values(r1) <- sample(80:100, 100, replace=TRUE)
plot(r1) ##Default Extent of xmn = -90, xmx=+90, ymn=-180, ymx=+180

enter image description here

r2 <- raster(xmn=0, xmx=10, ymn=0, ymx=10, ncol=10, nrow=10, crs="EPSG:4326")
values(r2) <- sample(80:100, 100, replace=TRUE)
plot(r2) ##Desired Extent of xmn = 0, xmx=10, ymn = 0, ymx = 10 

enter image description here