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 8495137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:29:15+00:00 2026-06-10T23:29:15+00:00

I am trying to create a package in R wherein I have created lots

  • 0

I am trying to create a package in R wherein I have created lots of new custom Classes. Each class is in a different file. The Classes inherit from a parent class and inherit to other classes.

While running my codes I call each of them like this

source("package/father.R")
source("package/son.R")
source("package/grandson.R")     

Definition for Some of the methods needed by the grandson Class in defined in Son class. I use package.skeleton() to call each of them and create a package and it seems to work fine. But when running R CMD Check(and when trying install into R), it throws an error because the function tries to call the files in the alphabetical order and so the file grandson.R is called before son.R and it shows and error saying that the methods has not been defined. If I change the names to zgrandson.R, R called that file the last, and everything seems to work fine, but this is evidently not a solution for the problem.

I have read tutorials for creating packages, but all of them seem to deal with simple cases where there is no inheritance/calling other files in R. Hope I have made myself clear.

  • 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-10T23:29:17+00:00Added an answer on June 10, 2026 at 11:29 pm

    As far as I understand, you can use the Collate field in the DESCRIPTION file to control this.

    Quoting from the Writing R Extensions manual:

    An ‘Collate’ field can be used for controlling the collation order for
    the R code files in a package when these are processed for package
    installation. The default is to collate according to the ‘C’ locale.
    If present, the collate specification must list all R code files in
    the package (taking possible OS-specific subdirectories into account,
    see Package subdirectories) as a whitespace separated list of file
    paths relative to the R subdirectory. Paths containing white space or
    quotes need to be quoted. An OS-specific collation field
    (‘Collate.unix’ or ‘Collate.windows’) will be used instead of
    ‘Collate’.

    So, you could specify:

    Collate:
      father.r
      son.R
      grandson.r
    

    Or simply rename the files in such a way that lexicographic sorting order will result in the correct collation order, as you indicated in your question.


    But also see this answer by @DirkEddelbuettel on a similar question.

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

Sidebar

Related Questions

I'm trying to create a NuGet package from a .csproj. I have successfully compiled
I am trying to create a Debain .deb package. Package is being created successfully
I am trying to create a multi-dimensional NetCDF file using the R package ncdf
I am trying to create a new package in BIDS but i get the
I am trying to create a Debian package for a Java application. In my
I am trying to create a sequenced SCORM 1.2 package with multiple modules in
Trying to create a new Dedicated Cache Role in Windows Azure but get the
I am trying to create 1 package with multiple build configurations. The first will
I'm trying to create an xpi package for a firefox addon through cfx tool.
I'm trying to create a function in package that returns a table. I hope

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.