I created a raster object (package raster in R) using the function rasterize starting from a shapefile of polygons. I passed as field a shapefile attribute (CODE) containing 37 landuse categories.
This is what I did in code:
myrast <- rasterize(x = shapefile, y = another_raster, field = shapefile$CODE)
The command converts the categorical variable into numbers from 1 to 37 and correctly create the raster.
Now I want to export the raster to see it in a GIS but I would like that a legend would be shown with the CODE and not with the number from 1 to 37.
How can I do this?