
Using XP_CMDSHELL
This method is by far the fastest and is very useful when sharing T-SQL code, but it compromises using the command shell and many users and DBAs are not keen on this. By enabling xp_cmdshell in configurations and using this stored procedure, you can install any missing package. Using code with the -e switch, you can easily install the library:
R cmd -e install.packages("Hmisc")
The following code will install the missing package on the R Server:
-- enable xp_cmdshell EXECUTE SP_CONFIGURE 'xp_cmdshell','1'; GO RECONFIGURE; GO EXEC xp_cmdshell '"C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\R_SERVICES\bin\R.EXE"cmd -e
install.packages(''Hmisc'')'; GO
Running Vanilla R and adding the install.packages() function can be done if the user has been granted the permission. The results are as follows:

Using CMD and the -e switch, the deployment and computation of R code can be executed and simplified, but since this is not an official way I would not suggest using this, since it exposes security issues.