profileLoadLibrary {QRMlib} | R Documentation |
The QRMlib package (QRMlib.dll) must be loaded into your QRMBook workspace before its
functions can be used by scripts.
The appropriate command to load a package into a workspace is
library(QRMlib)
It will be more convenient for you to add a “.Rprofile” file to your QRMBook workspace than
to invoke the library(QRMlib) command each time you start up. By adding .Rprofile to your
workspace, you will eliminate the need to load the library each time you run the workspace.
See details below for two ways to install a .Rprofile file into your workspace.
The installation program for QRMlib placed an .Rprofile file in the
...\library\QRMlib\inst\Chap2 folder. There is also a useful README.txt
in the ...\library\QRMlib folder.
In the Windows Explorer, merely copy the .Rprofile file from the QRM library
Chap2 folder into the QRMBook workspace your previously created to run scripts
(see QRMBook-workspace
). Once the .Rprofile file exists in your
QRMBook workspace, the QRMlib will automatically be loaded into the workspace.
Alternatively, you can build an .Rprofile file in your QRMBook folder using Notepad
or some other text editor. Just perform the following steps:
0. Close your R-workspace if it is open.
1. Copy the next nine lines of code (starting with .First and ending with })
into the clipboard.
.First <- function()
{
library(QRMlib)
}
.Last <- function()
{
detach(package:QRMlib)
}
2. Open Notepad: left-click the Start button, choose Run and
type notepad into the box. We will try to save a file named
“.Rprofile”. Note the entire file name is an extension with no
prefix. I.e. there will be no letters prior to the ‘.’ and the
type of file is an “Rprofile” type spelled with a capital R followed
by all small letters.
3. Paste the copied code into Notepad.
4. In Notepad, choose File | Save As from the menu.
5. In the resulting box, click the Save as Type drop-down box
and choose All Files.
(We are NOT saving as a .txt type.)
6. Paste the path
“C:\Program FilesRR-2.7.0\users\QRMBook\.Rprofile”
into the File name box. Be sure to spell .Rprofile
exactly as shown since R uses case sensitivity in opening files even
though Windows does not. Use R-2.8.0 or whatever higher version of
R you are using in place of R-2.7.0 if necessary.
7. Click the Save button.
You may now open your QRMBook workspace and the console should show that the
QRMlib, fSeries, mvtnorm, chron libraries have been loaded.
When you exit the R program, you will be asked whether to save the current workspace environment. If you choose to do so, the data files which you have opened via data(filename) calls will be saved in the workspace so you don't need to execute any subsequent data(filename) calls to get previously-loaded data. If you do not save the workspace, you must execute data(filename) each time you open the QRMBook workspace.
QRMBook-workspace
storeDataInWorkspace