: (colon), interaction terms, 396
= (equal sign), 19
$ (dollar sign)
referencing list elements, 77-79
shortened $ referencing, 78-79
\ (double backslash), 21
/ (forward slash), 21
[] (square brackets), 43
double square bracket referencing, 76-77
~ (tilde), formula relationships, 381
acf function, 448
active bindings, 544
adding
aggregate function, 252
multiple return values, 253-254
summarizing by multiple variables, 252-253
summarizing multiple columns, 253
aggregating data, 246
analysis of variance, comparing nested models, 395
anova function, 395
appending, 237-238. See also combining
applications, Shiny
sharing, 570
apply functions, 181-195, 250-251
applying to data frames, 193-195
order of “apply” inputs, 201-203
passing extra arguments to “applied” function, 188-191
tapply
multiple grouping variables, 209-210
return values, 212
using with higher dimension structures, 187-188
xapply, 182
arguments, 116
apply function, 183
breaks, 111
ellipsis, passing graphical parameters, 159-161
for merge function, 238
named arguments, 131
arima function, 449
ARIMA models, in time series analysis, 448-451
arrange function, 263
subscripting, 60
as.numeric function, 121
assessing models, 382
attributes
of data frames, querying, 87
of single mode data structures, comparing, 60-62
autocorrelations, in time series analysis, 448
axis limits, setting for plots, 294-295
bar charts, 291
Becker, Rick, 345
bigmemory package, 282
binaries, installing packages from, 26
bivariate lattice graphics, 350-351
boxplots, 290
breaks argument, 111
bugs, reporting, 8
building packages, 471-472, 482-485
c function, creating vectors, 35-36
C++
incorporating code in R, 501-502
capturing input definitions, 164-167
case sensitivity for file paths, 219
cbind function, 49
censoring in survival analysis, 431-432
character data
searching and replacing, 124-125
character value inputs, 48, 57-58, 76
checking
creating, constructor functions, 510-511
extending, 518
naming conventions, 512
methods
defining for arithmetic operators, 513-514
updating, 513
inheritance, 508
active bindings, 544
private members, 542
public members, 542
documenting, 542
removing, 510
S3, 509
documenting, 518
lists versus attributes, 514-515
naming conventions, 512
summary function and, 405
writing, 505
Cleveland, William, 345
clipboard, 219
closing graphics devices, 288
code
C++, incorporating in R, 501-502
improving efficiency
with memory management, 463-464
using alternative functions, 462-463
including in documents
LaTex documents, 556
profiling, 456
coefficients from logistic regression, 419-420
colon (:), interaction terms, 396
color function, 288
colors, specifying, 288
column index, 55
columns
selecting from data frames, 88
lists, 80
comment blocks, 15
comparing
reshape and reshape2 packages, 245
single mode data structures, 60-62
conferences, 6
confint function, 420
connecting
to Excel from R, 228
to R from Excel, 226
constructor functions, 510-511
continuation prompts, 15
continuous variables, creating factors, 111-112
contrast methods, 400
controlling
aesthetics in ggplot2 package, 322-324
styles for lattice graphics, 372-376
copying Reference Class objects, 540-542
core packages, 23
counting records, 281
covariates, in survival analysis, 436
CRAN, 7
METACRAN website, 24
navigating to, 573
packages
creating
classes
constructor functions, 510-511
with element names, 71
empty lists, 69
non-empty lists, 70
sequence of numeric values, 38-39
sequence of repeated values, 39-41
themes for lattice graphics, 374-376
CSV files, reading, 220
custom functions
applying over dimensions, 191-192
passing extra arguments, 192-193
ggplot function, 333
cut function, 111
data, including in packages, 494-496
data aggregation
aggregate function, 252
calculating differences from baseline, 257-258
“for” loops, 250
data argument (lm function), 381
attributes, querying, 87
columns, selecting, 88
referencing as a matrix, 90-92
returning top and bottom of data, 93-94
summarizing, 96
working with multiple, 336-338
“data” lattice graphics, 354-355
data munging, 235
numeric factors, 109
reordering, 110
DataCamp, 5
columns
data.tables
counting records, 281
date objects, creating, 103-104
dates
DBI (database interface), 225-226
decomposition, in time series analysis, 443-445
defining
methods
for arithmetic operators, 513-514
for Reference Classes, 537-540
time zones, 105
deleting packages, 24
deparse function, 166
dependencies, 27
descending sorts, 237
developing a test framework, 490-494
incorporating tests into packages, 493-494
devices (graphics)
devtools, building packages, 482-485
in GLM framework, 416
for time series analysis, 449-450
diff function, 106
difftime function, 106
dimensions
dropping, 56
distribution types, GLM framework, 412
distributions
statistical distributions, 119-120
documentation. See also dynamic reporting; reporting
interactive documents, 569-570
package documentation, generating, 477-482
R Documentation, 5
Reference Classes, 542
S3 class system, 518
vignettes
including in packages, 496-498
markdown notation, 499
double square bracket referencing, 76-77
mutate function, 266
sorting, 263
with filter function, 264
tbl_df objects, creating, 262-263
dropping dimensions, 56
code chunks, including, 550-552
HTML files, building, 550
dynamic typing, 19
EARL (Effective Applications of the R Language) conference, 6
Eclipse, 13
efficiency of code, improving
with memory management, 463-464
profiling, 456
using alternative functions, 462-463
elements
extracting from named lists, 84
list elements
passing graphical parameters, 159-161
empty lists, creating, 69
errors
bugs, reporting, 8
escape sequences, 21
estimating survival function in survival analysis, 432-436
example
of merge function, 239
connecting to R, 226
reading structured data, 226-227
exporting text files, 220
extending
classes, 518
extensions
to nonlinear models, 430
to survival analysis, 441
to time series analysis, 452
extracting elements from named lists, 84
factor variables
in logistic regression, 419
numeric factors, 109
reordering, 110
ff package, 282
file.choose function, 217
filter function, 264
finding
flow control, if/else statements, 136-146
mixing conditions, 143
returning early, 145
reversing logical values, 142-143
summarizing to a single logical, 140-141
switching with logical input, 141-142
using one condition, 139
foreign package, 222
formulas, using with aggregate function, 252-254
multiple return values, 253-254
summarizing by multiple variables, 252-253
summarizing multiple columns, 253
fread function, 221
functions
acf, 448
aggregate function, specifying variables, 254-256
anova, 395
applying to data frames, 193-195
passing extra arguments to “applied” function, 188-191
using with higher dimension structures, 187-188
arguments, 116
named arguments, 131
arima, 449
arrange, 263
as.numeric, 121
calling, 116
shortened argument calling, 162-161
cbind, 49
color, 288
confint, 420
constructor functions, 510-511
cut, 111
deparse, 166
diff, 106
difftime, 106
distribution functions, 119-120
error handling, 462
error messages, creating, 152-153
file.choose, 217
filter, 264
fread, 221
gc, 464
get, 164
ggplot, 333
glm, 413
I, 404
ifelse, 461
mixing conditions, 143
returning early, 145
reversing logical values, 142-143
summarizing to a single logical, 140-141
switching with logical input, 141-142
using one condition, 139
checking, 136, 155-157, 162-164
is.x, 122
order of “apply” inputs, 201-203
using with data frames, 203-204
library, 27
in nonlinear models, 428
logRange, 155
mathematical functions, 117-118
inner joins, 240
missing data functions, 122-123
mode, 34
mutate, 266
naming, 132
nchar, 123
ncol, 53
nested calls, 41
nrow, 53
objects, 18
odbcConnectAccess, 224
output, saving, 131
pacf, 448
in GLM framework, 416
in proportional hazards regression, 439-441
in survival analysis, 434
in time series analysis, 442-443
plyr, 213
in logistic regression, 419
in nonlinear models, 428
in survival analysis, 435
in time series analysis, 447
layers, 316
read.table, 218
remove.packages, 24
replace, 122
Rprof, 456
runif, 157
save, 22
self-starting, 427
separate, 249
spread, 248
sqlcolumns, 224
statistical summary functions, 118-119
stop, 152
substitute, 166
substring, 123
classes and methods, 405
with names function, 388
in proportional hazards regression, 439-441
switch, 159
table function, 121
tail, 94
multiple grouping variables, 209-210
return values, 212
UseMethod, 512
warning, 153
window, 443
xapply, 182
garbage collection, 464
Gaussian model fitting, 414
gc function, 464
generating
classes with constructor function, 510-511
documentation
package documentation with roxygen headers, 477-482
naming conventions, 512
Gentleman, Robert, 3
get function, 164
ggplot function, 333
ggplot2 package, 313
working with multiple data frames, 336-338
ggplot function, 333
legend layout, 341
plots
layers, 316
ggvis package, 342
GitHub, installing packages from, 26-27
GLM (Generalized Linear Model) framework
distribution types, 412
Gaussian model fitting, 414
glm function, 413
glm function, 413
Global Environment. See workspaces
graphical parameters, passing, 159-161
graphics
colors, 288
devices
closing, 288
ggplot2 package, 313
ggplot function, 333
legend layout, 341
ggvis package, 342
high-level graphics functions, plot, 291-299
lattice graphics, 345
graph types, 347
groups of data, representing, 360-362
plotting multiple variables, 358-360
plotting subsets of data, 355
low-level graphics functions, 299-304
trellis graphics, 345
graphing
bar charts, 291
Greek letters, adding to plots, 294
help pages, generating, 480-482
high-level graphics functions, plot, 291-299
histograms, 289
HTML files, building, 550
I function, 404
IDEs (integrated development environments), 13
Eclipse, 13
Notepad++, 13
ifelse function, 461
if/else statements
mixing conditions, 143
returning early, 145
reversing logical values, 142-143
summarizing to a single logical, 140-141
switching with logical input, 141-142
using one condition, 139
Ihaka, Ross, 3
Import Wizard, 218
importing text files, 218
improving code efficiency
with memory management, 463-464
profiling, 456
using alternative functions, 462-463
incorporating tests into packages, 493-494
independent variables
indexed printing, 36
inheritance, 508
inhibiting formula interpretation, 404
inner joins, 240
inputs
function inputs
checking, 136, 155-157, 162-164
order of “apply” inputs, 201-203
list subscripting inputs
blank inputs, 74
negative integer inputs, 75
positive integer inputs, 74-75
vector subscripting inputs, 44
character values, 48
positive integers, 45
installing
from binaries, 26
R, 573
on Mac OS X, 574
integers, creating sequence of, 37-38
interactive documents, 569-570
intercepts, removing, 381
is.x functions, 122
iteration, loops
“for” loops, 250
performance, 180
referencing data with, 176-177
joins
inner joins, 240
merging data in dplyr package, 267-268
Kaplan-Meier estimates, 433-434
keys
knitr package, 548
order of “apply” inputs, 201-203
using with data frames, 203-204
LaTex, 548
lattice graphics, 345
plot types and formatting, 357-358
graphs
types, 347
groups of data, representing, 360-362
controlling strip headers, 363-364
multiple “by” variables, 364-365
plotting multiple variables, 358-360
plotting subsets of data, 355
styles
previewing, 373
layers in quick plots, 316
layout
library function, 27
licenses for R packages, 475
multiple linear regression
comparing nested models, 393-395
updating existing models, 392-393
variable transformations, 402-404
in nonlinear models, 428
lines on plots, adding, 389-390
Linux
installing Rtools, 575
list objects, models as, 386-388
listing
empty lists, creating, 69
non-empty lists, creating, 70
combining, 80
with element names, creating, 71
elements
motivation for using, flexible simulation, 83-84
extracting elements from, 84
subscripting, 73
blank inputs, 74
character value inputs, 76
logical value inputs, 75
negative integer inputs, 75
positive integer inputs, 74-75
subsetting, 73
unnamed lists, 81
logical values
as list subscripting input, 75
as matrix subscripting input, 56-57
specifying, 36
as vector subscripting input, 46-47
logRange function, 155
loops
in C++, 467
performance, 180
referencing data with, 176-177
“while” loops, 174
low-level graphics functions, 299-304
Mac OX S
installing R, 574
installing Rtools, 575
mailing lists, 4
manipulating. See also sorting
margin values (apply function), 183-184
Markdown, 548. See also RMarkdown
mathematical functions, 117-118
column index, 55
dropping dimensions, 56
referencing data frames as, 90-92
subscripting, 55
merge function, 238-241, 267-268
inner joins, 240
METACRAN website, 24
methods, 512
defining for arithmetic operators, 513-514
parametric methods in survival analysis, 434-435
for Reference Classes, defining, 537-540
summary function and, 405
updating, 513
microbenchmark package, 457-458
Microsoft Excel. See Excel
missing data functions, 122-123
mode function, 34
models, 379
assessing, 382
GLM framework
distribution types, 412
Gaussian model fitting, 414
glm function, 413
variable transformations, 402-404
comparing nested models, 393-395
updating existing models, 392-393
nonlinear regression
assumptions, 423
extensions, 430
Puromycin data example, 425-429
survival analysis, 430
estimating survival function, 432-436
extensions, 441
ovarian data frame example, 431
proportional hazards regression, 437-441
time series analysis
autocorrelations, 448
extensions, 452
modes. See data types
motivation for using lists, flexible simulation, 83-84
multimode data structures, 36, 67-68
attributes, querying, 87
columns, selecting, 88
referencing as a matrix, 90-92
returning top and bottom of data, 93-94
working with multiple, 336-338
with element names, creating, 71
empty lists, creating, 69
non-empty lists, creating, 70
subscripting, 73
unnamed lists, 81
multiple linear regression
comparing nested models, 393-395
updating existing models, 392-393
Murrell, Paul, 313
mutate function, 266
named arguments, 131
extracting elements from, 84
names function, 42-43, 386-388
naming
functions, 132
generics, 512
objects, 20
S3 classes, 512
variables, 241
navigating to CRAN, 573
nchar function, 123
ncol function, 53
negative integer inputs, 45-46, 75
nested calls, 41
nested models, comparing, 393-395
nicknames, 7
non-empty lists, creating, 70
nonlinear regression
assumptions, 423
extensions, 430
Puromycin data example, 425-429
Notepad++, 13
nrow function, 53
numeric factors, 109
numeric values
inheritance, 508
objects, 16-22. See also packages
date objects, creating, 103-104
naming, 20
packages, 17
Reference Class objects, copying, 540-542
removing from workspace, 20
saving, 22
tbl_df objects, creating, 262-263
time objects, creating, 104-105
objects function, 18
odbcConnectAccess function, 224
operating systems
Mac OX S
installing R, 574
installing Rtools, 575
Windows
building packages, 482
clipboard, 219
arithmetic operators, defining methods for, 513-514
output of functions, saving, 131
ovarian data frame example (survival analysis), 431
pacf function, 448
bigmemory, 282
deleting, 24
dependencies, 27
documentation, generating with roxygen headers, 477-482
mutate function, 266
sorting, 263
dplyr package, creating tbl_df objects, 262-263
ff, 282
foreign, 222
ggplot2, 313
ggplot2 package
ggplot function, 333
legend layout, 341
ggvis package, 342
from binaries, 26
knitr, 548
lattice, 346
licenses, 475
masking, 28
METACRAN website, 24
proto, 544
repositories, 23
reshape, 243
sas7bdat, 223
interactive documents, 569-570
sharing applications, 570
separate function, 249
spread function, 248
markdown notation, 499
zoo, 123
Packages pane (RStudio), 24
with lattice graphics, 362-371
controlling strip headers, 363-364
multiple “by” variables, 364-365
parameters, setting for plotting functions, 304-305
parametric methods in survival analysis, 434-435
passing graphical parameters, 159-161
performance, loop performance, 180
plot function, 291-299, 383-385
in GLM framework, 416
paneling, facet_grid function, 329-331
in proportional hazards regression, 439-441
qplots, layers, 316
in survival analysis, 434
in time series analysis, 442-443
plots
ggplot function, 333
mulltiple data frames, 336-338
in GLM framework, 416
for time series analysis, 449-450
faceting, 333
layers, 316
plyr function, 213
positive integer inputs, 45, 74-75
POSIX functions, 105
in logistic regression, 419
in nonlinear models, 428
in survival analysis, 435
in time series analysis, 447
previewing lattice graphics styles, 373
printing
indexed printing, 36
profiling code, 456
proportional hazards regression, 437-441
proto package, 544
Puromycin data example (nonlinear regression), 425-429
faceting, 333
layers, 316
QQ plots, 289
querying
data frame attributes, 87
quotes, 34
object naming conventions, 20
installing, 573
on Mac OS X, 574
nicknames, 7
object orientation and, 405-406
user events, 6
R Development Core Team, 3
R Documentation, 5
R models. See models
active bindings, 544
private members, 542
public members, 542
Rcpp package, 464-468, 501-502
.RData format, 221
reading
CSV files, 220
structured data from Excel, 226-227
read.table function, 218
recommended packages, 23
records, counting, 281
re-creating simulated values, 120
documenting, 542
referencing
data frames as a matrix, 90-92
double square bracket referencing, 76-77
remove.packages function, 24
removing
classes, 510
intercepts, 381
objects from workspace, 20
reordering factors, 110
repeated values, creating sequence of, 39-41
replace function, 122
bugs, 8
repositories
CRAN
METACRAN website, 24
for packages, 23
representing groups of data, 360-362
reshape package, 243
restoring R sessions, 221
with reshape package, 243
spread function, 248
returning error messages, 152-153
reversing logical values, 142-143
RExcel, 13
RMarkdown, dynamic reporting, 548-552
code chunks, including, 550-552
HTML files, building, 550
roxygen headers, generating documentation with, 477-482
Rprof function, 456
Import Wizard, 218
Packages pane, 24
script window, 132
sessions, restoring, 221
Source pane, 16
text files
importing, 218
Rtools, installing on Windows, 575-577
runif function, 157
R Development Core Team, 3
R Documentation, 5
R models. See models
active bindings, 544
private members, 542
public members, 542
Rcpp package, 464-468, 501-502
.RData format, 221
reading
CSV files, 220
structured data from Excel, 226-227
read.table function, 218
recommended packages, 23
records, counting, 281
re-creating simulated values, 120
documenting, 542
referencing
data frames as a matrix, 90-92
double square bracket referencing, 76-77
remove.packages function, 24
removing
classes, 510
intercepts, 381
objects from workspace, 20
reordering factors, 110
repeated values, creating sequence of, 39-41
replace function, 122
reporting
bugs, 8
repositories
CRAN
METACRAN website, 24
for packages, 23
representing groups of data, 360-362
reshape package, 243
restoring R sessions, 221
with reshape package, 243
spread function, 248
returning error messages, 152-153
reversing logical values, 142-143
RExcel, 13
RMarkdown, dynamic reporting, 548-552
code chunks, including, 550-552
HTML files, building, 550
roxygen headers, generating documentation with, 477-482
Rprof function, 456
Import Wizard, 218
Packages pane, 24
script window, 132
sessions, restoring, 221
Source pane, 16
text files
importing, 218
Rtools, installing on Windows, 575-577
runif function, 157
documenting, 518
lists versus attributes, 514-515
naming conventions, 512
Sarkar, Deepayan, 346
sas7bdat package, 223
save function, 22
saving
function output, 131
workspace objects, 22
scoping rules for functions, 133-134
script window (RStudio), 132
scripting, 16
masking, 28
searching and replacing character data, 124-125
selecting columns from data frames, 88
self-starting functions, 427
separate function, 249
sequence of repeated values, creating, 39-41
server component of Shiny applications, 564-566
sharing Shiny applications, 570
applications
sharing, 570
interactive documents, 569-570
shortened $ referencing, 78-79
simulated values, re-creating, 120
simulating numeric values, 83-84
single mode data structures, 34-35. See also multimode data structures
column index, 55
dropping dimensions, 56
subscripting, 55
smoothing in time series analysis, 446-447
with arrange function, 263
descending sorts, 237
Source pane (RStudio), 16
special characters, adding to plots, 294
specifying
colors, 288
logical values, 36
variables for aggregate function, 254-256
splitting data frames, 197-199
S-PLUS, 3
spread function, 248
sqlcolumns function, 224
statistical distributions, 119-120
statistical models. See models
Statistical Sciences, Inc., 3
statistical summary functions, 118-119
stop function, 152
structure
of if/else statements, 136-146
of Shiny applications, 561-562
tidy structure, 243
structured data, reading from Excel, 226-227
styles for lattice graphics
previewing, 373
arrays, 60
with filter function, 264
lists, 73
blank inputs, 74
character value inputs, 76
logical values, 75
negative integer inputs, 75
positive integer inputs, 74-75
matrices, 55
character values, 48
positive integers, 45
subsets of time series, 443
subsetting lists, 73
substitute function, 166
substring function, 123
summarizing data frames, 96
summary function, 96, 382-383, 405
classes and methods, 405
with names function, 388
in proportional hazards regression, 439-441
survival analysis, 430
estimating survival function, 432-436
extensions, 441
ovarian data frame example, 431
proportional hazards regression, 437-441
switch function, 159
symbols, plotting symbols, 296-297
syntax
comment blocks, 15
continuation prompts, 15
lists
unnamed lists, 81
table function, 121
tail function, 94
multiple grouping variables, 209-210
return values, 212
tbl_df objects, creating, 262-263
test framework, developing, 490-494
incorporating tests into packages, 493-494
test-driven development, 494
exporting, 220
importing, 218
themes, creating for lattice graphics, 374-376
tidy data, 243
separate function, 249
spread function, 248
tilde (~), formula relationships, 381
time
time objects, creating, 104-105
time series analysis
autocorrelations, 448
extensions, 452
time zones, defining, 105
titles, labeling on plots, 293-294
transforming variables, 402-404
trellis graphics, 345
ui component of Shiny applications, 562-564
unnamed lists, 81
updating methods, 513
UseMethod function, 512
user events, 6
variables
continuous variables, creating factors, 111-112
factor variables
in logistic regression, 419
naming, 241
specifying for aggregate function, 254-256
character values, 48
positive integers, 45
nicknames, 7
vignettes, 477
including in packages, 496-498
markdown notation, 499
Visualizing Data, 345
visualizing data frames, 97-98
warnings for functions, returning, 153-155
websites
METACRAN, 24
R Documentation, 5
R Project website, 3
which argument (plot function), 385
“while” loops, 174
white space, 45
Wickham, Hadley, 213, 242, 261, 313
window function, 443
Windows operating system
building packages, 482
clipboard, 219
installing Rtools, 575
working directory, 21
objects
removing, 20
saving, 22
working directory, 21
writing
classes, 505
S3, 509
xapply function, 182
X-axis, labeling on plots, 293-295
XCode, installing Rtools, 575
Y-axis, labeling on plots, 293-295
zoo package, 123