add R version of https://issues.apache.org/jira/browse/SPARK-23916
[Github] Pull Request #21313 (huaxingao)