- Page 6: Doing matrix arithmeticAdding More
- Page 10 and 11: Preparing the dataDescribing Contin
- Page 12 and 13: Plotting Data in GroupsUsing data i
- Page 14 and 15: R For Dummies ®by Andrie de Vries
- Page 16 and 17: does not mean that the author or th
- Page 18 and 19: DedicationThis book is for my wife,
- Page 20 and 21: Publisher’s AcknowledgmentsWe’r
- Page 22 and 23: as your average scripting language,
- Page 24 and 25: This indicates that you type some c
- Page 26 and 27: In this part, we introduce the diff
- Page 28 and 29: Part IR You Ready?In this part . .
- Page 30 and 31: environment for their teaching clas
- Page 32 and 33: helping new users and advocating th
- Page 34 and 35: have to program a loop to achieve t
- Page 36 and 37: Chapter 2Exploring RIn This Chapter
- Page 38 and 39: for setting up collections of R scr
- Page 40 and 41: Closing the consoleTo quit your R s
- Page 42 and 43: Console: In the bottom-left corner,
- Page 44 and 45: Using vectorsA vector is the simple
- Page 46 and 47: like this:> h h[1] “Hello”You
- Page 48 and 49: Send a block of highlighted code to
- Page 50 and 51: Manipulating the content of the wor
- Page 52 and 53:
Chapter 3The Fundamentals of RIn Th
- Page 54 and 55:
the last name to all of them with o
- Page 56 and 57:
default method doesn’t always exi
- Page 58 and 59:
Names should contain only letters,
- Page 60 and 61:
Choosing a naming styleIf you have
- Page 62 and 63:
askets.of.GeraldineText Text[1]
- Page 64 and 65:
available. Finally, CRAN lets you c
- Page 66 and 67:
packages available on CRAN are chec
- Page 68 and 69:
Chapter 4Getting Started with Arith
- Page 70 and 71:
Operator Description Examplex + y y
- Page 72 and 73:
priority as the normal division ope
- Page 74 and 75:
For the logarithms with bases 2 and
- Page 76 and 77:
trunc(x) rounds to the nearest inte
- Page 78 and 79:
is.infinite(). The first function r
- Page 80 and 81:
preceding sections.Organizing Data
- Page 82 and 83:
Character vectors, containing textD
- Page 84 and 85:
seq(from = 4.5, to = 2.5, by = -0.5
- Page 86 and 87:
ep(1:3,length.out=7)[1] 1 2 3 1 2 3
- Page 88 and 89:
You can’t mix positive and negati
- Page 90 and 91:
To build logical vectors, you’d b
- Page 92 and 93:
Always put spaces around the less t
- Page 94 and 95:
undefined outcomes,” earlier in t
- Page 96 and 97:
FunctionWhat It Doessum(x)prod(x)mi
- Page 98 and 99:
Cumulating operationsSuppose that a
- Page 100 and 101:
You arrange the numbers in such a w
- Page 102 and 103:
Chapter 5Getting Started with Readi
- Page 104 and 105:
[1] 2> nchar(x)[1] 5 6Notice that t
- Page 106 and 107:
Looking at how named vectors workTo
- Page 108 and 109:
When you have text, you need to be
- Page 110 and 111:
[1] “some text in mixed case”To
- Page 112 and 113:
Recycling character vectorsWhen you
- Page 114 and 115:
head(state.names)[1] “Alabama”
- Page 116 and 117:
can confirm this by doing another f
- Page 118 and 119:
seemingly diverse syntax. If so, yo
- Page 120 and 121:
words[grep(“b(e*|a*)ch”, rwords
- Page 122 and 123:
Converting a factorSometimes you ne
- Page 124 and 125:
To look a little bit under the hood
- Page 126 and 127:
• Interval scaled data: You have
- Page 128 and 129:
printing results in the order that
- Page 130 and 131:
[1] “2012-07-27”> str(xd)Date[1
- Page 132 and 133:
FunctionDescriptionas.Date()weekday
- Page 134 and 135:
%a Abbreviated weekday name in the
- Page 136 and 137:
values that indicate the number of
- Page 138 and 139:
So, to add seven days to the Apollo
- Page 140 and 141:
An easy way to achieve this is to w
- Page 142 and 143:
Chapter 7Working in More Dimensions
- Page 144 and 145:
yrow takes a logical value that tel
- Page 146 and 147:
want to examine, and the second arg
- Page 148 and 149:
minus sign, and so forth.Using nume
- Page 150 and 151:
By default, R always tries to simpl
- Page 152 and 153:
does what? Both functions work much
- Page 154 and 155:
If a one-row matrix is simplified t
- Page 156 and 157:
Calculating row and column summarie
- Page 158 and 159:
Multiplying two matricesThe multipl
- Page 160 and 161:
If you check how my.vector looks li
- Page 162 and 163:
in our example we want each player
- Page 164 and 165:
The result of this is a data frame,
- Page 166 and 167:
One important difference between a
- Page 168 and 169:
As a careful reader, you noticed al
- Page 170 and 171:
new.baskets rownames(new.baskets)
- Page 172 and 173:
There are three main ways of adding
- Page 174 and 175:
It shouldn’t come as a surprise t
- Page 176 and 177:
length(baskets.list)[1] 2Extracting
- Page 178 and 179:
Assigning a new value to an element
- Page 180 and 181:
In order to be able to add the info
- Page 182 and 183:
apply a certain algorithm on a whol
- Page 184 and 185:
Chapter 8Putting the Fun in Functio
- Page 186 and 187:
To make this script into a function
- Page 188 and 189:
complex. The function comes with a
- Page 190 and 191:
}percent
- Page 192 and 193:
list yet. Actually, the only thing
- Page 194 and 195:
should use in the same way you did
- Page 196 and 197:
Chapter 4). You can’t use it befo
- Page 198 and 199:
R gurus will tell you that this “
- Page 200 and 201:
together with all objects in it.To
- Page 202 and 203:
notice that it uses an object contr
- Page 204 and 205:
object type.You can do that yoursel
- Page 206 and 207:
programmed in an object-oriented la
- Page 208 and 209:
Chapter 9Controlling the Logical Fl
- Page 210 and 211:
You could drop the argument pph and
- Page 212 and 213:
}tot.price priceCalculator(25,publ
- Page 214 and 215:
What happened? The warning message
- Page 216 and 217:
You can use this data frame now as
- Page 218 and 219:
In the previous example, you wanted
- Page 220 and 221:
A vector with values to loop over.
- Page 222 and 223:
executes. If you use 1:nclient, R c
- Page 224 and 225:
Every one of the apply functions ta
- Page 226 and 227:
The dimension or index over which t
- Page 228 and 229:
The second argument is the name of
- Page 230 and 231:
The lapply() function works exactly
- Page 232 and 233:
eturn the result you expect. The mi
- Page 234 and 235:
Here is another warning that pops u
- Page 236 and 237:
}logit(as.numeric(x))Copy and paste
- Page 238 and 239:
If you want to step through a funct
- Page 240 and 241:
logitpercent(‘50%’)[1] 0Start b
- Page 242 and 243:
the body of the function, as in the
- Page 244 and 245:
Did you forget to specify stringsAs
- Page 246 and 247:
list. Only then can you look for th
- Page 248 and 249:
Chapter 11Getting HelpIn This Chapt
- Page 250 and 251:
When you don’t know exactly what
- Page 252 and 253:
Another way of searching the web di
- Page 254 and 255:
In addition to these general mailin
- Page 256 and 257:
If you want to know what a minimal
- Page 258 and 259:
The hardest part of producing a min
- Page 260 and 261:
Part IVMaking the Data TalkIn this
- Page 262 and 263:
throughout this chapter.The edit()
- Page 264 and 265:
The backslash in “\t” is called
- Page 266 and 267:
of a spreadsheet. Finally, be sure
- Page 268 and 269:
nrows: If you want to read only a c
- Page 270 and 271:
functions in the foreign package.To
- Page 272 and 273:
project.org/package=RPostgreSQLSQLi
- Page 274 and 275:
Notice that the separator between f
- Page 276 and 277:
Iist.fileslist.dirsfile.existsfile.
- Page 278 and 279:
Chapter 13Manipulating and Processi
- Page 280 and 281:
Object Description CommentsvectorTh
- Page 282 and 283:
Subset Effect ExampleBlank Returns
- Page 284 and 285:
Alternatively, you can subset the d
- Page 286 and 287:
[1] 44 119 62 133 142> iris[index,
- Page 288 and 289:
adding calculated fields.If you use
- Page 290 and 291:
head(iris$ratio)[1] 1.457143 1.6333
- Page 292 and 293:
depending on the number of days of
- Page 294 and 295:
$ Illiteracy: num 2.1 1.5 1.8 1.9 1
- Page 296 and 297:
Understanding the different types o
- Page 298 and 299:
Making sense of %in%A very convenie
- Page 300 and 301:
R makes it easy to sort vectors in
- Page 302 and 303:
Just as before, you can sort the da
- Page 304 and 305:
List: Use the lapply() function to
- Page 306 and 307:
Using lapply() and sapply() to trav
- Page 308 and 309:
name Split, Apply, and Combine (SAC
- Page 310 and 311:
We won’t go deeper into this subj
- Page 312 and 313:
interface for reshaping data.Whippi
- Page 314 and 315:
When converting data between long a
- Page 316 and 317:
mgoals mgoalsGame Venue variable v
- Page 318 and 319:
Venue variable 1st 2nd 3rd 4th1 Bru
- Page 320 and 321:
single variable)Ensuring that all t
- Page 322 and 323:
sure your statistician sweats his p
- Page 324 and 325:
There are numerous other reasons fo
- Page 326 and 327:
All functions from the previous sec
- Page 328 and 329:
Finding the centerIn statistics, th
- Page 330 and 331:
You can specify the breaks in a cou
- Page 332 and 333:
The mpgdens list object contains
- Page 334 and 335:
Factor variables: summary() gives y
- Page 336 and 337:
You can let the whiskers always ext
- Page 338 and 339:
ow has Sepal.Width on the x-axis an
- Page 340 and 341:
Exclude observations with NA values
- Page 342 and 343:
A table like trial.table can be see
- Page 344 and 345:
You also can add the margins for on
- Page 346 and 347:
Chapter 15Testing Differences and R
- Page 348 and 349:
groups. (This function is part of t
- Page 350 and 351:
Between the square brackets, you ca
- Page 352 and 353:
shapiro.test(beaver2$temp)Shapiro-W
- Page 354 and 355:
The second line gives you the test
- Page 356 and 357:
When testing differences between tw
- Page 358:
esult.prop result.prop2-sample tes
- Page 361 and 362:
methods to extract the information.
- Page 363 and 364:
AOVModelCall:aov(formula = count ~
- Page 365 and 366:
$contrastsunordered ordered“contr
- Page 367 and 368:
Modeling linear relationsAn analysi
- Page 369 and 370:
These coefficients represent the in
- Page 371 and 372:
(Intercept) 37.2851 1.8776 19.858 <
- Page 373 and 374:
Getting the valuesFor example, a ca
- Page 375 and 376:
Part VWorking with GraphicsIn this
- Page 377 and 378:
and some large islands on Earth.Fir
- Page 379 and 380:
Now use the points() function to ad
- Page 381 and 382:
fit plot(faithful)> lines(faithful
- Page 383 and 384:
Box-and-whisker plot: Use the boxpl
- Page 385 and 386:
+ xlab = “Eruption time (min)”,
- Page 387 and 388:
The box typeTo change the type of b
- Page 389 and 390:
To change the font size of text ele
- Page 391 and 392:
Your result should look like Figure
- Page 393 and 394:
Chapter 17Creating Faceted Graphics
- Page 395 and 396:
Loading the lattice packageAlthough
- Page 397 and 398:
Base, grid, and lattice graphicsPer
- Page 399 and 400:
Changing the font size of titles an
- Page 401 and 402:
cex, pch, font: Control the charact
- Page 403 and 404:
plot. In our example, we want to en
- Page 405 and 406:
$ Employed : num 60.3 61.1 60.2 61.
- Page 407 and 408:
When you run this code, you’ll ge
- Page 409 and 410:
print(my.plot)Saving a lattice plot
- Page 411 and 412:
Each submitted package on CRAN also
- Page 413 and 414:
In this section, we discuss geoms a
- Page 415 and 416:
Each geom has a default stat, and e
- Page 417 and 418:
ggplot(quakes.agg, aes(x=depth, y=m
- Page 419 and 420:
according to x-value, whereas geom_
- Page 421 and 422:
Smoothing dataThe ggplot2 package a
- Page 423 and 424:
Your graphic should look like Figur
- Page 425 and 426:
+ scale_colour_discrete(name=”Cyl
- Page 427 and 428:
Chapter 19Ten Things You Can Do in
- Page 429 and 430:
nsmall: The minimum number of digit
- Page 431 and 432:
Making Choices with IfSpreadsheets
- Page 433 and 434:
mpgClass “High” “High” “H
- Page 435 and 436:
If you frequently work with tables
- Page 437 and 438:
Chapter 20Ten Tips on Working with
- Page 439 and 440:
command downloads the package from
- Page 441 and 442:
packages in the current applicable
- Page 443 and 444:
Conducting Installations from BioCo
- Page 445 and 446:
You can find detailed installation
- Page 447 and 448:
With this file, R will start up wit
- Page 449 and 450:
RStudio doesn’t save the history