Skip to content

Commit d6a37e1

Browse files
committed
tested miniCRAN with feedback from L. Grob
1 parent 2aa500b commit d6a37e1

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

docs/advanced-analytics/r/create-a-local-package-repository-using-minicran.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ As an output, miniCRAN creates an internally consistent repository consisting of
3232

3333
Experienced R users often look for the list of dependent packages in the DESCRIPTION file for the downloaded package. However, packages listed in **Imports** might have second-level dependencies. For this reason, we recommend use of the **miniCRAN** method.
3434

35-
3635
## What is a package repository
3736

3837
The goal of creating a local package repository is to provide a single location that a server administrator or other users in the organization can use to install new R packages on a server that does not have internet access. After creating the repository, you can modify it by adding new packages or upgrading the version of existing packages.
@@ -45,12 +44,12 @@ Package repositories are useful in these scenarios:
4544

4645
- **Easier offline installation**: To install package to an offline server requires that you also download all package dependencies, Using miniCRAN makes it easier to get all dependencies in the correct format.
4746

48-
- **Improved version management**: In a multiuser environment, there are good reasons to avoid unrestricted installation of multiple package versions on the server.
49-
50-
By using miniCRAN, you can avoid package dependency errors when preparing packages to install with the [CREATE EXTERNAL LIBRARY](https://docs.microsoft.com/sql/t-sql/statements/create-external-library-transact-sql) statement.
47+
By using miniCRAN, you can avoid package dependency errors when preparing packages to install with the [CREATE EXTERNAL LIBRARY](https://docs.microsoft.com/sql/t-sql/statements/create-external-library-transact-sql) statement.
5148

52-
You can also use miniCRAN to prepare packages for use in Azure Machine Learning. For more information, see this blog: [Using miniCRAN in Azure ML, by Michele Usuelli](https://www.r-bloggers.com/using-minicran-in-azure-ml/)
49+
- **Improved version management**: In a multiuser environment, there are good reasons to avoid unrestricted installation of multiple package versions on the server. Use a local repository to provide a consistent set of packages for use by your analysts.
5350

51+
> [!TIP]
52+
> You can also use miniCRAN to prepare packages for use in Azure Machine Learning. For more information, see this blog: [Using miniCRAN in Azure ML, by Michele Usuelli](https://www.r-bloggers.com/using-minicran-in-azure-ml/)
5453
5554
## Prepare packages using miniCRAN
5655

@@ -74,17 +73,18 @@ You begin by creating a **miniCRAN** repository to use as a source. You should c
7473

7574
### Step 2. Define a package source: a CRAN mirror, or an MRAN snapshot
7675

77-
1. Specify a mirror site to use in getting packages. This example specifies a particular snapshot from the MRAN site, but you should always open the MRAN site and find the latest snapshot.
76+
1. Specify a mirror site to use in getting packages. For example, you could use the MRAN site, or any other site in your region that contains the packages you need. If download fails, try another mirror site.
7877

7978
```R
80-
CRAN_mirror <- c(CRAN = "https://mran.microsoft.com/snapshot/2014-08-18_0233/")
79+
CRAN_mirror <- c(CRAN = "https://mran.microsoft.com")
80+
CRAN_mirror <- c(CRAN = "https://cran.cnr.berkeley.edu")
8181
```
8282

8383
2. Type the name of a local folder in which to store the collected packages.
8484

8585
Be sure to create the folder in advance. An error is raised if the `local_repo` folder does not exist when you run the R code later.
8686

87-
The folder should have a descriptive name. For example, avoid using "miniCRAN", and instead type something like "GeneticsPackages" or "TeamRPackages1.0.2".
87+
The folder should have a descriptive name. Here we've used "miniCRAN", but if you repeat this often, you should probably use a more descriptive name, such as "miniCRANZooPackages" or "miniCRANMyRPackagev2".
8888
8989
```R
9090
local_repo <- "~/miniCRAN"
@@ -114,8 +114,8 @@ You begin by creating a **miniCRAN** repository to use as a source. You should c
114114
3. Create the local repo. Be sure to change the R version if necessary
115115
116116
```R
117-
pkgs_expanded <- pkgDep(pkgs_needed, repos = CRAN_mirror)
118-
makeRepo(pkgs_expanded, path = local_repo, repos = CRAN_mirror, type = "win.binary", Rversion = "3.3")
117+
pkgs_expanded <- pkgDep(pkgs_needed, repos = CRAN_mirror);
118+
makeRepo(pkgs_expanded, path = local_repo, repos = CRAN_mirror, type = "win.binary", Rversion = "3.3");
119119
```
120120
121121
From this information, the miniCRAN package creates the folder structure that you need to copy the packages to the [!INCLUDE[ssNoVersion_md](..\..\includes\ssnoversion-md.md)] later.
@@ -125,9 +125,9 @@ You begin by creating a **miniCRAN** repository to use as a source. You should c
125125
You can run the following code to list the packages contained in the miniCRAN repository.
126126
127127
```R
128-
pdb <- as.data.frame(pkgAvail(local_repo, type = "win.binary", Rversion = "3.3"), stringsAsFactors = FALSE)
129-
head(pdb)
130-
pdb$Package
128+
pdb <- as.data.frame(pkgAvail(local_repo, type = "win.binary", Rversion = "3.3"), stringsAsFactors = FALSE);
129+
head(pdb);
130+
pdb$Package;
131131
pdb[, c("Package", "Version", "License")]
132132
```
133133
@@ -137,7 +137,7 @@ After you have created the repository and added the packages you need, you must
137137
138138
The following procedure describes how to install the packages using R tools.
139139
140-
1. Copy the folder containing the miniCRAN repository, in its entirety, to the server where you plan to install the packages.
140+
1. Copy the folder containing the miniCRAN repository, in its entirety, to the server where you plan to install the packages. The folder typically has this structure: miniCRAN root> -> bin -> windows -> contrib -> version no -> all packages.
141141
142142
2. Open an R command prompt using the R tool associated with the instance.
143143
@@ -152,18 +152,18 @@ The following procedure describes how to install the packages using R tools.
152152
3. Get the path for the instance library, and add it to the list of library paths.
153153
154154
```R
155-
.libPaths()[1]
156-
lib \<- .libPaths()[1]
155+
.libPaths()[1];
156+
lib <- .libPaths()[1]
157157
```
158158
159159
On SQL Server, this command should return the path of the library associated with the instance, such as: "C:/Program Files/Microsoft SQL Server/MSSQL14.MSSQLSERVER/R_SERVICES/library "
160160
161-
4. Specify the location on the server where you copied the **miniCRAN** repository in `server_repo`.
161+
4. Specify the new location on the server where you copied the **miniCRAN** repository, as `server_repo`.
162162
163-
In this example, we assume that you copied the repository to your user folder on the server.
163+
In this example, we assume that you copied the repository to a temporary folder on the server.
164164
165165
```R
166-
R server_repo <- "C:\\Users\\MyUserName\\miniCRAN"
166+
source_repo <- "C:\\temp\\miniCRAN"
167167
```
168168
169169
5. Since you are working in a new R workspace on the server, you must also furnish the list of packages to install.
@@ -175,7 +175,7 @@ The following procedure describes how to install the packages using R tools.
175175
6. Install the packages, providing the path to the local copy of the miniCRAN repo.
176176
177177
```R
178-
install.packages(tspackages, repos = file.path("file://", normalizePath(server_repo, winslash = "/")), lib = lib, type = "win.binary", dependencies = TRUE)
178+
install.packages(tspackages, repos = file.path("file://", normalizePath;(source_repo, winslash = "/")), lib = lib, type = "win.binary", dependencies = TRUE);
179179
```
180180
181181
7. From the instance library, you can view the installed packages using a command like the following:

0 commit comments

Comments
 (0)