How to rename an R package

Hi @jeremycolman, @maelle has a very good point there, but I am quite curious why what I said actually works....

See a minimal example:

First I just downloaded a tarball of a package (in this instance geosed) from CRAN, and unzip it a test-name folder in my Desktop folder....

This is how it looks at start the folder

fer@lemmus:~/Desktop/test-name$ ls -l
total 4
drwxr-xr-x 4 fer fer 4096 Nov  3 18:35 geosed

Now I build it using standard routines

fer@lemmus:~/Desktop/test-name$ R CMD build geosed
* checking for file ‘geosed/DESCRIPTION’ ... OK
* preparing ‘geosed’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘geosed_0.1.1.tar.gz’

Well, that's expected, it built geosed :slight_smile:

Now I simply change package name (see the screencapts of the minimal change of the first line of the DESCRIPTION file, from geosed to a more tasty blueAgedStilton):

geosed

geosed to blueAgedStilton

newname

This is the ONLY change I've made, and now I will rebuild geosed:

fer@lemmus:~/Desktop/test-name$ R CMD build geosed
* checking for file ‘geosed/DESCRIPTION’ ... OK
* preparing ‘blueAgedStilton’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘blueAgedStilton_0.1.1.tar.gz’

please NOTE that still I am building the same folder with exactly the same code as below and the name geosed, but R CMD build is reading the package with its new tastier blueAgedStilton name.

and checking again the folder:

fer@lemmus:~/Desktop/test-name$ ls -l
total 20
-rw-r--r-- 1 fer fer 7219 Nov  3 18:37 blueAgedStilton_0.1.1.tar.gz
drwxr-xr-x 4 fer fer 4096 Nov  3 18:36 geosed
-rw-r--r-- 1 fer fer 7202 Nov  3 18:36 geosed_0.1.1.tar.gz

Both tarball coexist.

Then in R:

install.packages("~/Desktop/test-name/blueAgedStilton_0.1.1.tar.gz", repos = NULL, type = "source")
Installing package into ‘/home/fer/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package ‘blueAgedStilton’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (blueAgedStilton)

## check it it is actually installed...

> library(blueAgedStilton)
> 
## no sign of error.

And one of the examples from the help files

> library(blueAgedStilton)
> sample_coord <-
+         matrix(
+              c(
+                  sample(327131680:419648450, 3) / 10000000,
+                  sample(-1147301410:-1241938690, 3) / 10000000
+              ),
+              ncol = 2
+          )
>      
>      # Generate sed center and radius
>      gtc <- geo_trivial_circle(sample_coord)
> 
> gtc
$radius
[1] 318.8123

$center
[1]   37.18726 -117.97616

$making
         [,1]      [,2]
[1,] 37.08444 -115.0803
[2,] 35.11864 -115.5170
[3,] 39.20222 -120.5720

Have a nice day!!
Fer

1 Like