Layer-based mapping for R