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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:49:41+00:00 2026-06-01T04:49:41+00:00

I have created an R script that it needs to load some libraries first.

  • 0

I have created an R script that it needs to load some libraries first.

The problem is that the script needs 1.6 seconds to finish its calculations (measured it many times with Linux command “time”) and 0.7 seconds only takes to load the libraries!

The script runs quite often, so the delay for library loading accounts to almost 80% of the real workload!

Is there any way to have the libraries preloaded so that they won’t be loaded each time the script runs?

Any other suggestion to bypass this slowness?

#!/usr/bin/Rscript

library(methods, quietly=TRUE, warn.conflicts = FALSE)
library(MASS, quietly=TRUE, warn.conflicts = FALSE)
library(RBGL, quietly=TRUE, warn.conflicts = FALSE)
library(igraph, quietly=TRUE, warn.conflicts = FALSE)
library(bnlearn, quietly=TRUE, warn.conflicts = FALSE)
library(gRbase, quietly=TRUE, warn.conflicts = FALSE)
library(gRain, quietly=TRUE, warn.conflicts = FALSE)
..
..
  • 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-01T04:49:42+00:00Added an answer on June 1, 2026 at 4:49 am

    If you turn your script into a package (which you should anyway, in the longer run …) then you can use Imports of just the symbols you need from the packages you use — which is typically a tad faster than a full load as done by Depends.

    So the key is to

    1. use a package
    2. learn about NAMESPACE
    3. import just the symbols you need.

    An orthogonal approach would be not to restart and to save that time — you could use Rserve as a resident R instance and just connect to it with an R client. Probably more work though…

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

Sidebar

Related Questions

I have created a script that saves some files in the Documents directory of
I have some Javascript code that needs to be dynamically created as a String
I have created a Greasemonkey script that runs fine in the firebug editor, with
I have created a PHP-script to update a web server that is live inside
I have created a dynamic list picker script using Jquery 1.3 and PHP that
I'm using SQL*Plus 9.2 on Oracle 10g enterprise. I have created some scripts that
I have some code that I have created for an OnChange event which works
i have a script that creates divs with some background image then moves them,
I have to create a script that takes a mySQL table, and exports it
I have php script that creates a temporary watermark image for users that are

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.