You need to ratify
your raster and give it some attributes, then write to GTiff format. Both a .tif and a .tif.aux.xml file will be written out, and ArcGIS can use the latter to derive symbology (QGIS sadly doesn't...). Example:
library(raster)
set.seed(1)
r <- raster(matrix(sample(c(1, 7:9, 19), 100, replace=TRUE), 10))
r <- ratify(r)
levels(r)[[1]]$NAME <- letters[1:nrow(levels(r)[[1]])]
# check results with levels(r)[[1]]
writeRaster(r, 'C:/DATA/r.tif')
Note that there's not much point doing this with continuous data, such surfaces should be reclassified first.
If you want a .dbf RAT that Arc will pick up automatically, this will work:
# datatype must be integer and raster must be single band
writeRaster(r, 'C:/DATA/r_2.tif', datatype = 'INT2S')
library(tidyverse)
as.data.frame(table(as.vector(r)),
stringsAsFactors = FALSE) %>%
rename(VALUE = Var1, COUNT = Freq) %>%
# you can add some more cols here,
# just keep nchar() < 254 and colnames < 8 chars:
mutate(VALUE = as.integer(VALUE)) %>%
foreign::write.dbf(., 'C:/DATA/r_2.tif.vat.dbf',
factor2char = TRUE, max_nchar = 254)