How to avoid re-installing R packages every time we start R

Every time I start R, I have to re-install the packages I need and also call from the library ("library" command). It is wasting the time, this problem seems very basic. What is the solution for this? I do not want to re-install packages I use regularly. Following is the error I got for the function "dynlm" once I re-start R today as you can guess (however, I already installed the package and used the "dynlm" function yesterday):

WUdlm <- dynlm(WU$GARCHVar.ts ~ L(WU$GARCHVar.ts, 1) + L(WU$GARCHVar.ts, 12))
Error in dynlm(WU$GARCHVar.ts ~ L(WU$GARCHVar.ts, 1) + L(WU$GARCHVar.ts, :
could not find function "dynlm"

Thank you,


Welcome the forum!

You shouldn't have to re-install packages each time you open R. If library(dynlm) doesn't work without re-installing then I would say this is definitely an issue.

However, you do generally need to load the packages you want to use in that session via library(). Did you try to run library(dynlm) in your current R session without re-installing it first?


Thank you!

That worked. Library() loaded the function and it worked.

One more issue :slight_smile: I am using read.csv() to upload the data/variables. When we shut down and re-start R, I need to upload the data using read.csv(). How can I keep or save the data/variables within R so that I do not need to upload again when R is re-started? Or is there a more efficient way to uplload and keep the data/variables other than read.csv() ?

1 Like

You should probably mark the question as answered and ask a new question. I think you'll get more readers who could potentially answer your new question and it is easier in the long term to have separate issues in separate questions.

I pretty much always start in a vanilla R session with nothing loaded and then read in datasets with functions like read.csv(). Since I do all my work in scripts (.R or .Rmd), it's pretty simple to run the already written line of code again. However, you can have R save and then load a .RData file into your workspace on start up. I can't tell you much about it since this is a feature I've never used it :grin:, but someone may come along to your new question and be able to give you more details.


Thanks again :slight_smile: Marked answered as well..

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.