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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:58:33+00:00 2026-05-20T12:58:33+00:00

Part of my project directory structure looks like: \projects\project\main.R \projects\project\src where \src contains a

  • 0

Part of my project directory structure looks like:

\projects\project\main.R
\projects\project\src

where \src contains a bunch of 1-function-per-file, project-specific functions.

Q: What’s the best practice way to add these functions to the working directory projects\project?

There are a few solutions I see:

  1. attach("./src"). I’m trying to avoid this because (1) the Google Styleguide recommends avoiding the use of attach() and (2) I receive the

    Warning messages:
    

    1: Reading Unix style database directory (./tmp) from Splus on Windows: may
    have problems finding some datasets, especially those whose names
    differ only by case (file tmp-script1.ssc should not have been made by
    Splus on Windows) in: exists(name, where = db)

    when doing this.

  2. lapply(paste("./src/",list.files("./src/"),sep=""),source). This works perfectly fine, it just seems clunky. There has to be a better way, right?

  3. Refer to my functions by their full name ./src/myfunc. This will get ugly very quick. I’m sure there’s a better way.

  4. Get rid of the ./src part of my directory and just throw all the functions in the main working directory. The problem with this is that I’d prefer to keep with a directory structure that is close to that of John Myles White’s ProjectTemplate

  5. Throw all the functions in one file, ./src/func.R and source that. I guess this approach avoids the ugliness of “2.” above, but I’d really like to have one function per file. Just seems cleaner that way.

  • 1 1 Answer
  • 1 View
  • 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-05-20T12:58:33+00:00Added an answer on May 20, 2026 at 12:58 pm

    Try

    lapply(list.files("src", full.names = TRUE), source)
    

    EDIT

    or

    lapply(Sys.glob("src/*"), source)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project where the directory structure is like this: $projectroot | +---------------+----------------+
I have a c++ project which directory structure like below: server/ code/ BASE/ Thread/
I have an Xcode4 project which is under Subversion SCM. The initial directory structure
I'm working with a project that is setup using the standard Maven directory structure
Here is the task-related part of the VS2010 project (Windows Phone) structure: The code
As part of a project I have assigned myself as a way of improving
As part of my project I need to use some Unamanged code dlls in
For part of a project I'm working on I am implementing a RTPpacket where
As part of a project with a partner, we are required to provide single-sign-on
I am a part of TFS project. We use Visual Studio 2005. It was

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.