Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:11:59+00:00 2026-06-13T04:11:59+00:00

Is there a function that expands the path to the actual subdirectory containing package

  • 0

Is there a function that expands the path to the actual subdirectory containing package binaries (or whatever the equivalent under Linux and Mac OS is called) given the URL-like path to a local repository’s root directory in an OS-independent manner?

Due Dilligence

Related Links

  • SO post
  • R Manual

Suppose you have a repository under L:/my_repo:

path.repo <- "L:/my_repo"

MS Windows requires a certain subdirectory structure:

path.sub  <- file.path("bin/windows/contrib", paste(version$major, 
    gsub("(?<=\\d)\\.\\d", "", version$minor, perl=TRUE), sep=".")
)

Actually create the repository:

dir.create(file.path(path.repo, path.sub), recursive=TRUE, showWarnings=FALSE)

Once a package binary exists in the repository, the repository’s index needs to be created:

setwd(file.path(path.repo, path.sub))
tools::write_PACKAGES(".", type="win.binary")

After that, the repository is good to go and you could install its packages via

install.packages(“mypackage”, repos=file.path(“file://”, path.repo))

So far, so good. I’d like to create a function that automatically copies a package binary to my local repository once the package binary has been built. In order to do so, I guess I need to retrieve the path to the actual directory containing the binaries and the two index files (PACKAGES' andPACKAGES.gz`). And that should happen in an OS-independent way in order to make it as generic as possible.

Of course I could search for the index files via

unique(dirname(grep("PACKAGE*", list.files(path.repo, recursive=TRUE, 
    full.names=TRUE), value=TRUE)))

But I wonder if there’s a better way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:12:00+00:00Added an answer on June 13, 2026 at 4:12 am

    This is what I came up so far. It borrows from the code in contrib.url():

    expandPathRepos=function(
        path,
        type="win.binary",
        vsn=paste(version$major, gsub("(?<=\\d)\\.\\d", "", 
            version$minor, perl=TRUE), sep="."), 
        ...
    ) {
        if (!type %in% c("source", "mac.binary", "win.binary")) {
            stop(paste("Invalid type: '", type, "'", sep=""))
        }
        out <- switch(unlist(type), 
            source=paste(gsub("/$", "", path), 
                "src", "contrib", sep = "/"), 
            mac.binary=paste(gsub("/$", "", path), "bin", "macosx", 
                mac.subtype, "contrib", ver, sep="/"), 
            win.binary=paste(gsub("/$", "", path), 
                "bin", "windows", "contrib", vsn, sep = "/")
        )
        return(out)
    }
    
    expandPathRepos(path="L:/R")
    [1] "L:/R/bin/windows/contrib/2.14"
    

    Any other ideas?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any function that does the inverse operation of array_diff() ? I mean,
Is there a function that can truncate or round a Double? At one point
Is there a function that tells what class you are extending? Like function_exists? I
Is there a function that takes 1,2,3 and returns 3,1,2 respectively and vice-verse. eg:
Is there some function that returns the parent directory of a file in Perl?
Is there a function that can round a float in Fsharp? Something like round(3.21156,3)
Is there any function that do the opposite job of QString::split() . I mean
In Javascript is there a function that returns the number of times that a
for C, is there a function that takes an int and doesn't execute next
is there a wordpress function that I can use to detect pages? example of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.