data("wrld_simpl", package = "maptools")
library(raster)
## Loading required package: sp
r <- rasterize(wrld_simpl, raster(extent(-180, 180, -90, 90), crs = "+init=epsg:4326",
nrow = 144, ncol = 72))
## r is a categorical raster, i.e there's a data.frame of values index by ncell(r)
library(ggplot2)
## notice how "layer_" gets prepended to the column names in wrld_simpl
ggplot(as.data.frame(r, xy = TRUE)) + geom_raster(aes(x, y, fill = factor(layer_REGION)))