Any time R session restarts you'll need to reload any packages your code depends on.
If it's really important, you can automatically load packages each time you open a project with a .Renviron file. But that can lead to issues with reproducibility.
Sean Lopp wrote a nice article on RStudio's startup process here:
Another discussion from Colin Gillespie's Efficient R programming >> 3.3 R startup
https://csgillespie.github.io/efficientR/3-3-r-startup.html#r-startup
In my experience, the 'package not available' most frequently occurs when I had a typo in the package name, for exmaple:
install.packages('thispackagedoesnexists')
#> Installing package into 'C:/Users/OKComputer/Documents/R/win-library/3.5'
#> (as 'lib' is unspecified)
#> Warning: package 'thispackagedoesnexists' is not available (for R version
#> 3.5.0)
Created on 2018-08-08 by the reprex package (v0.2.0).
If I've completely missed your point (wouldn't be my first time!), could you supply a reprex of the error or additional details, such as system info?
system Information that is often helpful
#### System Information:
- RStudio Edition: (Desktop or Server)
- RStudio Version:
- OS Version:
- R Version:
#### Also:
<!-- Depending on your issue, the following may be useful /-->
<!-- If a section isn't relevant or you can't collect it just delete that section below /-->
- RStudio diagnostics report: <!--see rstd.io/support-diagnostics-report /-->
- Your `sessionInfo()`:
- RStudio crash report: <!-- rstd.io/support-crash-report /-->
- RStudio application log files: <!-- rstd.io/support-ide-log-files /-->