Tải bản đầy đủ
Appendix C. The R Commander Graphical User Interface

Appendix C. The R Commander Graphical User Interface

Tải bản đầy đủ

mand into the R Script window of R Commander and select it. To
select a command, click the beginning of the line, drag across the
line to the end, and release the mouse button. The line will now be
highlighted. Click the Submit button, and R will execute the com‐

Figure C-1. The R Commander GUI interface for R.
Try working through the strip chart problems in Chapter 3 using R
Commander. At the top of the screen, on the menu bar, click Data.
On the menu that opens, choose “Data in packages” and “Read data‐
set from an attached package.” Figure C-2 shows the window that
opens, in which you can select the trees data set. Click OK.



Appendix C: The R Commander Graphical User Interface

Figure C-2. Selecting a dataset in R Commander for analysis with R.
Below the menu bar, you will see that trees is now the active data‐
set. Continue by selecting “strip chart” from the Graphs window.
Compare your result to the first chart in Chapter 3. Next, try to
duplicate the second chart, the one that demonstrates jittering.
(Hint: after you open the strip chart window, click “options.”) You
will not be able to replicate the other charts in that chapter by using
only the GUI. If you want to produce the third graph, you can sub‐
mit a command line to R in the R Script window. The easiest way to
do this is to edit the command line produced when you made the
previous graph. Just add the pch=20 parameter and edit the xlab
argument (see Figure C-3). When you have the command the way
you want it, select it and then click Submit.

The R Commander Graphical User Interface



Figure C-3. Using the R Script window to submit a command line to R.
If you like R Commander, try to replicate some other examples from
the book with this GUI. In many cases, it will not be hard to figure
out what to do if you know how the graph should look. For more
complex graphs, you will need to type a command.
It is possible to extend R Commander (i.e., add more commands).
You can do this by using a plug-in. As I write this, 36 plug-ins are
available to be installed, just the way you would install other pack‐
ages. Most of them add many new commands. It is also possible to
write your own. For more information, click Help on the menu bar,
or see the R Commander web page at http://www.rcommander.com,
the author’s web page at http://socserv.mcmaster.ca/jfox/Misc/
Rcmdr/, or the complete list of R packages at http://cran.rproject.org/web/packages/available_packages_by_name.html. Scroll
down to the entries that begin with “RcmdrPlugin.”
Many of the plug-ins have one or more graphical functions. To see
how plug-ins work, install RcmdrPlugin.HH. The package HH con‐
tains a number of useful graphic functions. The plug-in makes these
functions available from R Commander. First, install the package:

| Appendix C: The R Commander Graphical User Interface

> install.packages("RcmdrPlugin.HH", dependencies=TRUE)

Next, start R Commander:
> library(Rcmdr)

When the R Commander screen opens, on the menu bar, click
Graphs. Get a sense of how many options there are without the
plug-in. To load the plug-in, click the Tools option on the Menu bar
and select “Load Rcmdr plug-ins.” On the menu that follows, select
the plug-in name. Now, look at the Graphs option again: you will
notice many more choices than before, all in the bottom half of the
menu. Some of these add really useful options. For example, the
Scatterplot.HH plug-in offers much greater control of output (such
as type and size of plot character), several kinds of lines to put on
the graph, and even the ability to click a point and have it identified.
Several other plug-ins include nice graphic functions, too. Unlike
RcmdrPlug.HH, some of them will add a new menu to the menu bar.
Among the ones that add interesting graphs are RcmdrPlu‐
gin.KMggplot2, RcmdrPlugin.NMBU, RcmdrPlugin.EZR, and oth‐

The R Commander Graphical User Interface




Packages Used/Referenced





James Honaker
Gary King
Matthew Blackwell

Program for missing data


Hans Peter Wolf
Uni Bielefeld

Another Plot PACKage: adds
stem.leaf(), bagplot(),
faces(), spin3R(), plotsum
mary(), plothulls(), and

some slider functions

John Fox
Sanford Weisberg

Companion to Applied Regression


Taiyun Wei

Visualization of a correlation matrix


Andri Signorell
Other contributors

Tools for descriptive statistics


Andreas Schulz

Easy Plots


Virasakdi Chongsuvivatwong

Epidemiological calculator


R Core Team

Read data stored by Minitab, S, SAS,
SPSS, Stata, Systat, Weka, dBase...


Barret Schloerke
Jason Crowley
Di Cook
Heike Hofmann
Hadley Wickham
Francois Briatte
Moritz Marbach
Edwin Thoen

Extension to ggplot2






Hadley Wickham
Winston Chang

An implementation of the Grammar
of Graphics


Gregory R. Warnes
other contributors

Various R programming tools for
model fitting


John W. Emerson
Walton A. Green

Produces a generalized pairs
(gpairs) plot


Gregory R. Warnes
Ben Bolker
Lodewijk Bonebakker
Robert Gentleman
Wolfgang Huber
Andy Liaw
Thomas Lumley
Martin Maechler
Arni Magnusson
Steffen Moeller
Marc Schwartz
Bill Venables

Various R programming tools for
plotting data


Paul Murrell

The Grid Graphics Package


Dan Carr
Other contributors

Hexagonal Binning Routines


Michael Friendly
Stephane Dray
Hadley Wickham
James Hanley
Dennis Murphy

Datasets from the history of
statistics and data visualization


Frank E. Harrell Jr,
Other contributors

Harrell Miscellaneous


Deepayan Sarkar

Lattice Graphics


Deepayan Sarkar
Felix Andrews

Extra Graphical Utilities Based on


Torston Hothorn
Frank Bretz
Peter Westfall
Other contributors

Simultaneous Inference in General
Parametric Models


David Pierce

Interface to Unidata netCDF data


Jose Pinheiro
Douglas Bates
Other contributors

Linear and Nonlinear Mixed Effects



Appendix D: Packages Used/Referenced





Jim Lemon, Ben Bolker, Sander
Oom, Eduardo Klein, Barry
Rowlingson, Hadley Wickham,
Anupam Tyagi,
Olivier Eterradossi, Gabor
Grothendieck, Michael Toews, John
Kane, Rolf Turner, Carl Witthoft,
Julian Stander, Thomas Petzoldt,
Remko Duursma, Elisa Biancotto,
Ofir Levy,
Christophe Dutang, Peter Solymos,
Robby Engelmann,
Michael Hecker, Felix Steinbeck,
Hans Borchers,
Henrik Singmann, Ted Toal, Derek

Various plotting functions


William Revelle

Procedures for Psychological,
Psychometric, and Personality


Raymond McTaggart
Gergely Daroczi

Quandl Data Connection


John Fox
Milan Bouchet-Valat
Other contributors

A platform-independent basicstatistics GUI (graphical user
interface) for R, based on the
tcltk package


John Fox
Other contributors

R Commander Miscellaneous


Yoshinobu Kanda

R Commander Plug-in for the EZR
(Easy R) Package


Richard M. Heiberger
Contributions from Burt Holland

Rcmdr support for the HH package


Triad sou
Kengo Nagashima

Rcmdr Plug-in for Kaplan-Meier
Plots and Other Plots by Using the
ggplot2 Package


Kristian Hovde Liland
Solve Sæbø

R Commander Plug-in for Statistics


Mohamed Abdolell
Sam Stewart

Using GUIs to help teach statistics to
non-statistics students

Hadley Wickham

Flexibly reshape data: a reboot of
the reshape package

Daniel Adler
Duncan Murdoch
Other contributors

3D Visualization Using OpenGL


Packages Used/Referenced |






Uwe Ligges
Martin Maechler
Sarah Schnackenberg

3D Scatter Plot


Duncan Temple Lang

General network (HTTP/FTP/...)
client interface for R


F. L. Ramsey
D. W. Schafer
Other contributors

Data sets from Ramsey and Schafer


Adrian Bowman
Adelchi Azzalini

Smoothing methods for
nonparametric regression and
density estimation


David Meyer
Achim Zeileis
Kurt Hornik
Other contributors

Visualizing Categorical Data


Mirai Solutions GmbH
Martin Studer
Other contributors

Excel Connector for R


Duncan Temple Lang

Reading and creating XML (and
HTML) documents



Appendix D: Packages Used/Referenced


Importing Data from Outside of R

Some Useful Internet Data Repositories
There are many websites from which you can download datasets
and to analyze with R. A few sources are presented in the list that
follows, as examples of the vast universe of shared data. In many
cases, it is necessary to register to use the datasets and/or agree to
terms of use. Carefully read the requirements of any provider from
whom you plan to acquire data. Datasets from the following sources
are frequently offered in Excel or CSV format, which have already
been discussed in the section “Reading from an External File” on
page 16; some examples in other formats follow:
Open Access Directory (http://oad.simmons.edu/oadwiki/Main_Page)
This site provides links to downloadable data from many sources
on diverse subjects, especially the sciences. Many of the datasets are
free; some you must purchase. Scroll down the table of contents to
“Data repositories” to see the variety of topics covered. Scroll down
this page to “Social sciences” and choose from the listing:
FedStats (http://fedstats.sites.usa.gov/)
This is a repository of many kinds of United States federal govern‐
ment data freely available to the public. This page has links to vari‐
ous government agencies sharing data.
DATA.GOV (http://catalog.data.gov/dataset)
This is another repository of federal data.


Quandl (http://www.quandl.com)
This is a repository of more than 10 million datasets that are avail‐
able for free download in several formats, including R data frames.
Compared to many other sources, Quandl is easy to work with.
Install and load the Quandl package:
> install.packages("Quandl")
> library(Quandl)

Browse the Quandl web page until you find a file that you want.
For example, suppose that you chose the FBI “Crimes by State”
file for Pennsylvania at http://www.quandl.com/FBI_UCR/
USCRIME_STATE_PENNSYLVANIA. You can load it into an R
data frame, penn.crime, with one command:

Importing Data of Various Types into R
R can read data in many different formats. Importing data from
some of the most important ones is discussed in this section.

Our first example is a simple CSV file from the National Science
Foundation. Note that it looks very much like the example in the
section “Reading from an External File” on page 16; however,
because this file is not in a working directory on your computer, you
must include the entire URL in quotes—identifying the web page
from which it comes—as shown here:
> nsf2011 = read.csv(

Statistical Packages (SPSS, SAS, Etc.)
I found an interesting dataset at the Association of Religion Data
Archives (http://www.thearda.com). After reading about ARDA,
click Data Archive on the Menu bar at the top of the page to see
what datasets are available. Datasets come in many different for‐
mats. As an example, you can download “The Gravestone Index,”
collected by Wilbur Zelinsky, at http://www.thearda.com/Archive/
Files/Downloads/CEMFILE_DL.asp in any of three versions. Two
formats, SPSS and Stata, were designed for rival statistical software
packages. An R package called foreign can translate either of these

| Appendix E: Importing Data from Outside of R