Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find location of package?

Tags:

package

r

I am building an R package (let's call it "pkg"), and would like to write a function that downloads a file from the internet and saves it in the "inst/extdata" directory in my package's directory.

 download_file <- function(link) { 
     path <- ... # path to where "pkg" is stored
                 # something along the lines of ....../pkg
     download.file(link, paste(path, "inst/extdata", "newfile", sep = ""))
 }

Could you please help me get the "path"? While developing the package, I can just do "getwd()" -- however, when a user calls my package, her working directory might not be the pkg directory. In which case, how do I get the path to my package's directory?

like image 774
Karan Tibrewal Avatar asked Feb 27 '17 17:02

Karan Tibrewal


People also ask

How do I find the location of a Python package?

When a package is installed globally, it's made available to all users that log into the system. Typically, that means Python and all packages will get installed to a directory under /usr/local/bin/ for a Unix-based system, or \Program Files\ for Windows.

Can I track my package in real-time?

A USPS parcel tracking number is a unique set of numbers assigned to your order. This USPS tracking number can be used to track your USPS package and receive real-time updates from USPS on your parcels.

Where can I find R packages?

R packages are installed in a directory called library. The R function . libPaths() can be used to get the path to the library.


1 Answers

Just run .libPaths() and it will show you the filepath to your library folder. Inside the library folder you can see all your packages.

like image 54
user3507584 Avatar answered Sep 20 '22 19:09

user3507584