#LyX 1.6.7 created this file. For more info see http://www.lyx.org/
\lyxformat 345
\begin_document
\begin_header
\textclass scrbook
\begin_preamble
\input{preamble.tex}
\end_preamble
\use_default_options false
\language english
\inputencoding utf8
\font_roman lmodern
\font_sans helvet
\font_typewriter courier
\font_default_family default
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\float_placement H
\paperfontsize default
\spacing single
\use_hyperref true
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks false
\pdf_backref false
\pdf_pdfusetitle true
\papersize letterpaper
\use_geometry false
\use_amsmath 2
\use_esint 1
\cite_engine basic
\use_bibtopic false
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\bullet 0 5 11 -1
\bullet 1 5 24 -1
\bullet 2 0 0 -1
\tracking_changes false
\output_changes false
\author ""
\author ""
\end_header
\begin_body
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
input{chapter.tex}
\end_layout
\end_inset
\end_layout
\begin_layout Chapter
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
,
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
, and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
-- Windows
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
epigraph{Education is not the piling on of learning, information, data,
facts, skills, or abilities---that's training or instruction---but is rather
making visible what is hidden as a seed.}{Sir Thomas More}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Installing a functional
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
integration with
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
can be tricky.
This chapter lists instructions for a functioning
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
environment.
\end_layout
\begin_layout Standard
In this chapter:
\end_layout
\begin_layout Itemize
\series bold
Prerequisites.
\series default
Lists the software packages required to begin the installation.
\end_layout
\begin_layout Itemize
\series bold
Installation.
\series default
Enumerates the steps for installing
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
.
\end_layout
\begin_layout Itemize
\series bold
Configuration.
\series default
Describes how to ready
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
for integration with
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
.
\end_layout
\begin_layout Itemize
\series bold
Validation.
\series default
Verifies that
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
code can be called from within
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
.
\end_layout
\begin_layout Section
Prerequisites
\end_layout
\begin_layout Standard
Before the instructions in this chapter can be executed successfully,
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
must be installed and fully functional.
\end_layout
\begin_layout Section
Installation
\end_layout
\begin_layout Standard
This section describes how to install
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
.
The versions of
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
must be congruent.
For example, if you downloaded
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
2.11.1, you must download and install the corresponding version of
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
.
The
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
filename contains
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
filename{r211}
\end_layout
\end_inset
for
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
version 2.11.x.
The versions of
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
must also match.
For example, if you downloaded
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
8.4.6-1, then you must download and install the corresponding version of
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
.
The
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
filename contains
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
filename{pg84}
\end_layout
\end_inset
for
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
version 8.4.x.
\end_layout
\begin_layout Subsection
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
To install
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
:
\end_layout
\begin_layout Enumerate
Download the version of
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
listed in
\begin_inset CommandInset ref
LatexCommand vref
reference "tab:Windows-Applications-Versions"
\end_inset
.
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
\begin_inset CommandInset href
LatexCommand href
target "http://cran.r-project.org/bin/windows/base/old/"
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Enumerate
Run the
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
setup program.
\end_layout
\begin_layout Enumerate
Select the desired language.
\end_layout
\begin_layout Enumerate
Click
\series bold
OK
\series default
.
\end_layout
\begin_layout Enumerate
Click
\series bold
Next
\series default
to accept all defaults on every screen.
\end_layout
\begin_layout Enumerate
Click
\series bold
Finish
\series default
to close the installer.
\end_layout
\begin_layout Standard
R is now installed, but not configured.
\end_layout
\begin_layout Subsection
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
To install
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
:
\end_layout
\begin_layout Enumerate
Download the version of
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
listed in
\begin_inset CommandInset ref
LatexCommand vref
reference "tab:Windows-Applications-Versions"
\end_inset
.
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
\begin_inset CommandInset href
LatexCommand href
target "http://www.joeconway.com/plr/"
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Enumerate
Run the
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
setup program.
\end_layout
\begin_layout Enumerate
Continue through the installation program.
\end_layout
\begin_layout Enumerate
Click
\series bold
Yes
\series default
when prompted (
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:PL/R-Folder-Exists"
\end_inset
).
\end_layout
\begin_deeper
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Graphics
filename captures/plr-install-01.png
display false
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:PL/R-Folder-Exists"
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
Install - Folder Exists
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\end_deeper
\begin_layout Enumerate
Click
\series bold
Install
\series default
.
\end_layout
\begin_layout Enumerate
Continue through the installation program.
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
is now installed, but not configured.
\end_layout
\begin_layout Section
Configuration
\end_layout
\begin_layout Standard
This section describes how to configure
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
and
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
.
\end_layout
\begin_layout Subsection
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
After you have downloaded
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
(see
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Windows-Applications-Versions"
\end_inset
), upgrade all
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
packages to the latest version as follows:
\end_layout
\begin_layout Enumerate
Start
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
to see
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:R"
\end_inset
.
\end_layout
\begin_deeper
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Graphics
filename captures/r.png
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:R"
\end_inset
R
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\end_deeper
\begin_layout Enumerate
Type:
\end_layout
\begin_deeper
\begin_layout LyX-Code
\family typewriter
update.packages()
\end_layout
\end_deeper
\begin_layout Enumerate
Select the mirror closest to your location, using the dialog shown in
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:R-Mirror"
\end_inset
.
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
Updating packages from Australia, unless you live there, will be slow.
\end_layout
\end_inset
\end_layout
\begin_deeper
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Graphics
filename captures/r-mirror.png
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:R-Mirror"
\end_inset
R Mirror
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\end_deeper
\begin_layout Enumerate
Click
\series bold
OK
\series default
.
\end_layout
\begin_layout Enumerate
If prompted, type
\family typewriter
Y
\family default
at each prompt to upgrade the package.
\end_layout
\begin_layout Enumerate
Click
\series bold
File
\begin_inset Quotes ald
\end_inset
Exit
\series default
to quit
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
.
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
Or type
\family typewriter
q()
\family default
to quit
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
.
\end_layout
\end_inset
\end_layout
\begin_layout Enumerate
When prompted to
\series bold
Save workspace image
\series default
, click
\series bold
No
\series default
.
\end_layout
\begin_layout Enumerate
Click
\series bold
Start
\begin_inset Quotes ald
\end_inset
Settings
\begin_inset Quotes ald
\end_inset
Control Panel
\series default
.
\end_layout
\begin_layout Enumerate
Open
\series bold
System
\series default
.
\end_layout
\begin_layout Enumerate
Click
\series bold
Advanced
\series default
.
\end_layout
\begin_layout Enumerate
Click
\series bold
Environment Variables
\series default
.
\end_layout
\begin_layout Enumerate
Select the
\series bold
Path
\series default
variable (
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:R-Path-Variable"
\end_inset
).
\end_layout
\begin_deeper
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Graphics
filename captures/r-environment-variables.png
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:R-Path-Variable"
\end_inset
R - Path Environment Variable
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\end_deeper
\begin_layout Enumerate
Click
\series bold
Edit
\series default
.
\end_layout
\begin_layout Enumerate
If the path does not already contain it, append the following text:
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
Be sure to change the version number if a different version of R was installed.
\end_layout
\end_inset
\end_layout
\begin_deeper
\begin_layout LyX-Code
;C:
\backslash
Program Files
\backslash
R
\backslash
R-2.11.1
\backslash
bin
\end_layout
\end_deeper
\begin_layout Enumerate
Click
\series bold
OK
\series default
to close the
\series bold
Edit System Variable
\series default
dialog.
\end_layout
\begin_layout Enumerate
Click
\series bold
OK
\series default
to close the
\series bold
Environment Variables
\series default
dialog.
\end_layout
\begin_layout Enumerate
Click
\series bold
OK
\series default
to close the
\series bold
System Properties
\series default
dialog.
\end_layout
\begin_layout Enumerate
Restart
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
.
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
In rare situations, the computer might need to be rebooted for the changes
to take effect.
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
is configured.
\end_layout
\begin_layout Subsection
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
To configure
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
:
\end_layout
\begin_layout Enumerate
Open a command prompt.
\end_layout
\begin_layout Enumerate
Type:
\end_layout
\begin_deeper
\begin_layout LyX-Code
\family typewriter
cd "
\backslash
Program Files
\backslash
PostgreSQL
\backslash
8.4
\backslash
share
\backslash
contrib
\backslash
"
\end_layout
\begin_layout LyX-Code
\family typewriter
..
\backslash
..
\backslash
bin
\backslash
psql.exe -U postgres < plr.sql
\end_layout
\end_deeper
\begin_layout Enumerate
Type the postgres user's password when prompted.
\end_layout
\begin_deeper
\begin_layout Standard
Note: The password will be displayed on the screen.
\end_layout
\end_deeper
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
is configured.
\end_layout
\begin_layout Section
Validation
\end_layout
\begin_layout Standard
To test that
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
is installed correctly:
\end_layout
\begin_layout Enumerate
Click
\series bold
Start
\begin_inset Quotes ald
\end_inset
Programs
\begin_inset Quotes ald
\end_inset
PostgreSQL 8.4
\begin_inset Quotes ald
\end_inset
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppgadmin{}
\end_layout
\end_inset
\series default
to start the
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
Administration tool.
\end_layout
\begin_layout Enumerate
Right-click on
\series bold
PostgreSQL 8.4
\series default
.
\end_layout
\begin_layout Enumerate
Select connect.
\end_layout
\begin_layout Enumerate
Type in the postgres user password when prompted.
\end_layout
\begin_layout Enumerate
Click
\series bold
OK
\series default
.
\end_layout
\begin_layout Enumerate
Expand
\series bold
PostgreSQL
\begin_inset Quotes ald
\end_inset
Databases
\begin_inset Quotes ald
\end_inset
postgres
\series default
.
\end_layout
\begin_layout Enumerate
Click
\series bold
postgres
\series default
to highlight it.
\end_layout
\begin_layout Enumerate
Click the
\series bold
Execute arbitrary SQL queries
\series default
icon, on the toolbar shown in
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:pgAdmin-Toolbar"
\end_inset
.
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
The toolbar icons differ between versions of pgAdmin.
\end_layout
\end_inset
\end_layout
\begin_deeper
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Graphics
filename captures/pgadmin-toolbar.png
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:pgAdmin-Toolbar"
\end_inset
pgAdmin Toolbar
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\end_deeper
\begin_layout Enumerate
Press
\series bold
CTRL-a
\series default
to highlight, and subsequently replace, any existing text.
\end_layout
\begin_layout Enumerate
Type:
\end_layout
\begin_deeper
\begin_layout Standard
\family typewriter
SELECT * FROM plr_environ()
\end_layout
\end_deeper
\begin_layout Enumerate
Press
\series bold
F5
\series default
to execute the query.
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
environment variables appear as a list of key-value pairs.
\end_layout
\begin_layout Section
Summary
\end_layout
\begin_layout Standard
Leveraging
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appr{}
\end_layout
\end_inset
from
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
apppostgres{}
\end_layout
\end_inset
(through
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
appplr{}
\end_layout
\end_inset
) opens an exploratory avenue to investigate data in ways that only statistics
can reveal.
Configuring these software packages to inter-operate produces reports that
engage readers by showing data trends that might not be apparent otherwise.
\end_layout
\end_body
\end_document