- Install Packages In Rstudio
- Install Packages In R From
- Install Packages In R Studio
- Install Packages In R Syntax
In theory the package should just install, however: if you are using Linux and don’t have root access, this command won’t work. You will be asked to select your local mirror, i.e. Which server should you use to download the package. Recommended Packages. Many useful R function come in packages, free libraries of code written by R's active user community. To install an R package, open an R session and type at the command line. Install.packages('package's name>') R will download the package from CRAN, so you'll need to be connected to the internet. A repository is a place where packages are located so you can install them from it. Although you or your organization might have a local repository, typically they are online and accesible to everyone. Three of the most popular repositories for R packages are: CRAN: the official repository. The RStudio team contributes code to many R packages and projects. R users are doing some of the most innovative and important work in science, education, and industry. It’s a daily inspiration and challenge to keep up with the community and all it is accomplishing. The tidyverse is an opinionated collection of R packages designed for data science.
Active11 months ago
How we can get the list of installed packages by user in R along with its version?
I know about the command
installed.packages()
which will give information about all packages (base or non-base). But how we can get those installed by user to have something like this:For all user installed packages (i.e. those package you installed via
install.packages('X')
)989
9899899,43555 gold badges2020 silver badges3939 bronze badges
4 Answers
TomTom
Install Packages In Rstudio
I just found another ways to see the list of the packages without writing any code:
- Open RStudio
- Navigate to
Help --> R Help
(from the menu above) - You will see the help panel opened.
- Then follow,
Reference --> Packages
There you are.
OR
- Open R console
- Navigate to
Help --> Html help
- Then follow,
Reference --> Packages
9,43555 gold badges2020 silver badges3939 bronze badges
AkshayNevrekar6,8971212 gold badges2323 silver badges4545 bronze badges
C k khamariC k khamari
If I develop an app or model and want to record the package versions used, I call
sessionInfo()
SeanosapienSeanosapien
Not the answer you're looking for? Browse other questions tagged rpackages or ask your own question.
-->This article describes how to use functions in the sqlmlutils package to install new R packages to an instance of SQL Server Machine Learning Services or SQL Server R Services. The packages you install can be used in R scripts running in-database using the T-SQL sp-execute-external-script-transact-sql statement.
Note
The standard R
install.packages
command is not recommended for adding R packages on SQL Server. Instead, use sqlmlutils as described in this article.Prerequisites
- Install R and RStudio Desktop on the client computer you use to connect to SQL Server. You can use any R IDE for running scripts, but this article assumes RStudio.
- Install Azure Data Studio or SQL Server Management Studio (SSMS) on the client computer you use to connect to SQL Server. You can use other database management or query tools, but this article assumes Azure Data Studio or SSMS.
Other considerations
- R script running in SQL Server can use only packages installed in the default instance library. SQL Server cannot load packages from external libraries, even if that library is on the same computer. This includes R libraries installed with other Microsoft products.
- On a hardened SQL Server environment, you might want to avoid the following:
- Packages that require network access
- Packages that require elevated file system access
- Packages used for web development or other tasks that don't benefit by running inside SQL Server
Install sqlmlutils on the client computer
To use sqlmlutils, you first need to install it on the client computer you use to connect to SQL Server.
The sqlmlutils package depends on the RODBCext package, and RODBCext depends on a number of other packages. The following procedures install all of these packages in the correct order.
Install sqlmlutils online
If the client computer has Internet access, you can download and install sqlmlutils and its dependent packages online.
- Download the latest sqlmlutils zip file from https://github.com/Microsoft/sqlmlutils/tree/master/R/dist to the client computer. Don't unzip the file.
- Open a Command Prompt and run the following commands to install the packages sqlmlutils and RODBCext. Substitute the full path to the sqlmlutils zip file you downloaded (this example assumes the file is in your Documents folder). The RODBCext package is found online and installed.
Install sqlmlutils offline
If the client computer doesn't have an Internet connection, you need to download the packages sqlmlutils and RODBCext in advance using a computer that does have Internet access. You then can copy the files to a folder on the client computer and install the packages offline.
The RODBCext package has a number of dependent packages, and identifying all dependencies for a package gets complicated. We recommend that you use miniCRAN to create a local repository folder for the package that includes all the dependent packages.For more information, see Create a local R package repository using miniCRAN.
The sqlmlutils package consists of a single zip file that you can copy to the client computer and install.
On a computer with Internet access:
- Install miniCRAN. See Install miniCRAN for details.
- In RStudio, run the following R script to create a local repository of the package RODBCext. This example creates the repository in the folder
c:downloadsrodbcext
.For theRversion
value, use the version of R installed on SQL Server. To verify the installed version, use the following T-SQL command. - Download the latest sqlmlutils zip file from https://github.com/Microsoft/sqlmlutils/tree/master/R/dist (don't unzip the file). For example, download the file to
c:downloadssqlmlutils_0.7.1.zip
. - Copy the entire RODBCext repository folder (
c:downloadsrodbcext
) and the sqlmlutils zip file (c:downloadssqlmlutils_0.7.1.zip
) to the client computer. For example, copy them to the folderc:temppackages
on the client computer.
On the client computer you use to connect to SQL Server, open a command prompt and run the following commands to install RODBCext and then sqlmlutils.
Add an R package on SQL Server
In the following example, you'll add the glue package to SQL Server.
Add the package online
If the client computer you use to connect to SQL Server has Internet access, you can use sqlmlutils to find the glue package and any dependencies over the Internet, and then install the package to a SQL Server instance remotely.
- On the client computer, open RStudio and create a new R Script file.
- Use the following R script to install the glue package using sqlmlutils. Substitute your own SQL Server database connection information.TipThe scope can be either PUBLIC or PRIVATE. Public scope is useful for the database administrator to install packages that all users can use. Private scope makes the package available only to the user who installs it. If you don't specify the scope, the default scope is PRIVATE.
Add the package offline
Install Packages In R From
If the client computer doesn't have an Internet connection, you can use miniCRAN to download the glue package using a computer that does have Internet access. You then copy the package to the client computer where you can install the package offline.See Install miniCRAN for information on installing miniCRAN.
On a computer with Internet access:
- Run the following R script to create a local repository for glue. This example creates the repository folder in
c:downloadsglue
.For theRversion
value, use the version of R installed on SQL Server. To verify the installed version, use the following T-SQL command. - Copy the entire glue repository folder (
c:downloadsglue
) to the client computer. For example, copy it to the folderc:temppackagesglue
.
On the client computer:
- Open RStudio and create a new R Script file.
- Use the following R script to install the glue package using sqlmlutils. Substitute your own SQL Server database connection information.TipThe scope can be either PUBLIC or PRIVATE. Public scope is useful for the database administrator to install packages that all users can use. Private scope makes the package available only to the user who installs it. If you don't specify the scope, the default scope is PRIVATE.
Install Packages In R Studio
Use the package
Once the glue package is installed, you can use it in an R script in SQL Server with the T-SQL sp_execute_external_script command.
Install Packages In R Syntax
- Open Azure Data Studio or SSMS and connect to your SQL Server database.
- Run the following command:Results
Remove the package
If you would like to remove the glue package, run the following R script. Use the same connection variable you defined earlier.
Next steps
- For information about installed R packages, see Get R package information
- For help in working with R packages, see Tips for using R packages
- For information about installing Python packages, see Install Python packages with pip
- For more information about SQL Server Machine Learning Services, see What is SQL Server Machine Learning Services (Python and R)?