Extract source code from package r

I am trying to install package r and, unfortunately, it is too old to be implemented in newer versions of r .

According to the author, you can use the package using the source() function to access the code, but I could not figure out how to do this.

Any help is appreciated.

Here is a link to the package that I described, as it is not a CRAN package: http://tocsy.pik-potsdam.de/wavelets/

+4
source share
2 answers

. A ZIP file is a Windows binary, and therefore it will not be too interesting. What you want to see is the contents of the .tar.gz archive. You can extract this content, and then look at the code in the R subdirectory.

You can also upgrade the package to work with new versions of R so that you can actually create and install the package. To do this, you can unzip the .tar.gz file as before, but now you need to add the NAMESPACE file. This is just a plaintext file at the top of the package directory, which has a form like:

 export(createar) export(createwgn) export(criticalvaluesWCO) export(criticalvaluesWSP) export(cwt.ts) export(plot.wt) export(plotwt) export(readmatrix) export(readts) export(rk) export(wco) export(wcs) export(writematrix) export(wsp) 

If you have an export statement for any package function that you really want to use. If the function is not exported, then the functions in the package still have access to this function, but the user cannot use it (as easy). After that, you can create and install the package.

I took the liberty of making any of this already. I actually did not find the time to figure out which functions are useful and should be exported, and simply assumed that if a help page was written for the function that it should export, and if there was no help page, then export it. I used Rd2roxygen to convert the help pages to roxygen code (because it's like I roll), and after that you had to clean up the cleanup a bit, but it seems to be just fine.

So, if you have the devtools package installed, you can really install the version that I modified directly using the following commands

 library(devtools) install_github("SOWAS", "Dasonk") 

Personally, I would recommend that you go along the path of adding the NAMESPACE file, and not directly, because then you will have more control over the code and you can fix any problems that may occur when using the package. Or, if you use git, you can unlock my repo and continue to fix things from there. Good luck.

+4
source

If you want to see the source code of a specific function, simply enter the name of the function without curly braces and press enter. You will see the code.

For example, type var at a command prompt to see it.

 > var function (x, y = NULL, na.rm = FALSE, use) { if (missing(use)) use <- if (na.rm) "na.or.complete" else "everything" na.method <- pmatch(use, c("all.obs", "complete.obs", "pairwise.complete.obs", "everything", "na.or.complete")) if (is.na(na.method)) stop("invalid 'use' argument") if (is.data.frame(x)) x <- as.matrix(x) else stopifnot(is.atomic(x)) if (is.data.frame(y)) y <- as.matrix(y) else stopifnot(is.atomic(y)) .Call(C_cov, x, y, na.method, FALSE) } <bytecode: 0x0000000008c97980> <environment: namespace:stats> 
+1
source

Source: https://habr.com/ru/post/1442507/


All Articles