The package "PSTricks" implements layers in the R language above the PSTricks macro package for LaTeX (and TeX) by providing wrapper functions for many of the macros.
Higher-level functions are also available to produce plots, including some "ggplot2"-like functions with a similar, but not completely identical, functionality.
When using these functions, an R object is created with the associated LateX lines, which is by default automatically converted to a PDF document.
A more complete description is given in https://github.com/olofsen/PSTricks-for-R/blob/main/book/_book/PSTricksBook.pdf