Download full R Markdown: The Definitive Guide Yihui Xie ebook all chapters
Download full R Markdown: The Definitive Guide Yihui Xie ebook all chapters
Download full R Markdown: The Definitive Guide Yihui Xie ebook all chapters
com
https://textbookfull.com/product/r-markdown-the-
definitive-guide-yihui-xie/
https://textbookfull.com/product/fashion-the-definitive-visual-guide-
caryn-franklin/
textbookfull.com
https://textbookfull.com/product/javascript-the-definitive-guide-7th-
edition-david-flanagan/
textbookfull.com
https://textbookfull.com/product/xie-s-veterinary-acupuncture-
huisheng-xie-vanessa-preast/
textbookfull.com
https://textbookfull.com/product/public-confidence-in-criminal-
justice-a-history-and-critique-1st-edition-elizabeth-r-turner-auth/
textbookfull.com
World Trade and Local Public Interest: Trade
Liberalization and National Regulatory Sovereignty Csongor
István Nagy
https://textbookfull.com/product/world-trade-and-local-public-
interest-trade-liberalization-and-national-regulatory-sovereignty-
csongor-istvan-nagy/
textbookfull.com
https://textbookfull.com/product/new-directions-in-literature-and-
medicine-studies-1st-edition-stephanie-m-hilger-eds/
textbookfull.com
https://textbookfull.com/product/exploring-the-rules-the-dating-
playbook-4-1st-edition-mariah-dietz/
textbookfull.com
https://textbookfull.com/product/on-the-scent-a-journey-through-the-
science-of-smell-1st-edition-pelosi/
textbookfull.com
R Markdown
The Definitive Guide
Chapman & Hall/CRC
The R Series
Series Editors
John M. Chambers, Department of Statistics Stanford University Stanford,
California, USA
Torsten Hothorn, Division of Biostatistics University of Zurich Switzerland
Duncan Temple Lang, Department of Statistics University of California,
Davis, California, USA
Hadley Wickham, RStudio, Boston, Massachusetts, USA
Yihui Xie
J. J. Allaire
Garrett Grolemund
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable
efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication
and apologize to copyright holders if permission to publish in this form has not been obtained. If any
copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access
www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc.
(CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization
that provides licenses and registration for a variety of users. For organizations that have been granted
a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and
are used only for identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
To Jung Jae-sung (1982 – 2018),
a remarkably hard-working badminton player with a remarkably
simple playing style
Contents
Preface xxiii
I Get Started 1
1 Installation 3
2 Basics 5
2.1 Example applications . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 Airbnb’s knowledge repository . . . . . . . . . . . . 9
2.1.2 Homework assignments on RPubs . . . . . . . . . . 10
2.1.3 Personalized mail . . . . . . . . . . . . . . . . . . . 10
2.1.4 2017 Employer Health Benefits Survey . . . . . . . . 11
2.1.5 Journal articles . . . . . . . . . . . . . . . . . . . . . 12
2.1.6 Dashboards at eelloo . . . . . . . . . . . . . . . . . 12
2.1.7 Books . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.8 Websites . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Compile an R Markdown document . . . . . . . . . . . . . 14
2.3 Cheat sheets . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4 Output formats . . . . . . . . . . . . . . . . . . . . . . . . 16
2.5 Markdown syntax . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.1 Inline formatting . . . . . . . . . . . . . . . . . . . 19
2.5.2 Block-level elements . . . . . . . . . . . . . . . . . 20
2.5.3 Math expressions . . . . . . . . . . . . . . . . . . . 23
2.6 R code chunks and inline R code . . . . . . . . . . . . . . . 24
2.6.1 Figures . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6.2 Tables . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.7 Other language engines . . . . . . . . . . . . . . . . . . . . 30
vii
viii Contents
2.7.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.7.2 Shell scripts . . . . . . . . . . . . . . . . . . . . . . 34
2.7.3 SQL . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.7.4 Rcpp . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.7.5 Stan . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.7.6 JavaScript and CSS . . . . . . . . . . . . . . . . . . 39
2.7.7 Julia . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.7.8 C and Fortran . . . . . . . . . . . . . . . . . . . . . 40
2.8 Interactive documents . . . . . . . . . . . . . . . . . . . . . 41
2.8.1 HTML widgets . . . . . . . . . . . . . . . . . . . . 41
2.8.2 Shiny documents . . . . . . . . . . . . . . . . . . . 42
II Output Formats 47
3 Documents 49
3.1 HTML document . . . . . . . . . . . . . . . . . . . . . . . 49
3.1.1 Table of contents . . . . . . . . . . . . . . . . . . . . 50
3.1.2 Section numbering . . . . . . . . . . . . . . . . . . 51
3.1.3 Tabbed sections . . . . . . . . . . . . . . . . . . . . 51
3.1.4 Appearance and style . . . . . . . . . . . . . . . . . 52
3.1.5 Figure options . . . . . . . . . . . . . . . . . . . . . 54
3.1.6 Data frame printing . . . . . . . . . . . . . . . . . . 55
3.1.7 Code folding . . . . . . . . . . . . . . . . . . . . . . 56
3.1.8 MathJax equations . . . . . . . . . . . . . . . . . . . 57
3.1.9 Document dependencies . . . . . . . . . . . . . . . 58
3.1.10 Advanced customization . . . . . . . . . . . . . . . 59
3.1.11 Shared options . . . . . . . . . . . . . . . . . . . . . 62
3.1.12 HTML fragments . . . . . . . . . . . . . . . . . . . 62
3.2 Notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.2.1 Using Notebooks . . . . . . . . . . . . . . . . . . . 63
3.2.2 Saving and sharing . . . . . . . . . . . . . . . . . . 72
3.2.3 Notebook format . . . . . . . . . . . . . . . . . . . 73
3.3 PDF document . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.3.1 Table of contents . . . . . . . . . . . . . . . . . . . . 79
3.3.2 Figure options . . . . . . . . . . . . . . . . . . . . . 80
3.3.3 Data frame printing . . . . . . . . . . . . . . . . . . 80
3.3.4 Syntax highlighting . . . . . . . . . . . . . . . . . . 81
3.3.5 LaTeX options . . . . . . . . . . . . . . . . . . . . . 81
3.3.6 LaTeX packages for citations . . . . . . . . . . . . . 82
3.3.7 Advanced customization . . . . . . . . . . . . . . . 83
Contents ix
4 Presentations 93
4.1 ioslides presentation . . . . . . . . . . . . . . . . . . . . . . 93
4.1.1 Display modes . . . . . . . . . . . . . . . . . . . . . 95
4.1.2 Incremental bullets . . . . . . . . . . . . . . . . . . 95
4.1.3 Visual appearance . . . . . . . . . . . . . . . . . . . 96
4.1.4 Code highlighting . . . . . . . . . . . . . . . . . . . 98
4.1.5 Adding a logo . . . . . . . . . . . . . . . . . . . . . 98
4.1.6 Tables . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.1.7 Advanced layout . . . . . . . . . . . . . . . . . . . 100
4.1.8 Text color . . . . . . . . . . . . . . . . . . . . . . . 100
4.1.9 Presenter mode . . . . . . . . . . . . . . . . . . . . 101
4.1.10 Printing and PDF output . . . . . . . . . . . . . . . 101
4.1.11 Custom templates . . . . . . . . . . . . . . . . . . . 101
4.1.12 Other features . . . . . . . . . . . . . . . . . . . . . 102
4.2 Slidy presentation . . . . . . . . . . . . . . . . . . . . . . . 102
4.2.1 Display modes . . . . . . . . . . . . . . . . . . . . . 104
4.2.2 Text size . . . . . . . . . . . . . . . . . . . . . . . . 104
4.2.3 Footer elements . . . . . . . . . . . . . . . . . . . . 105
4.2.4 Other features . . . . . . . . . . . . . . . . . . . . . 105
4.3 Beamer presentation . . . . . . . . . . . . . . . . . . . . . . 106
4.3.1 Themes . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.3.2 Slide level . . . . . . . . . . . . . . . . . . . . . . . 108
4.3.3 Other features . . . . . . . . . . . . . . . . . . . . . 109
4.4 PowerPoint presentation . . . . . . . . . . . . . . . . . . . 109
4.4.1 Custom templates . . . . . . . . . . . . . . . . . . . 112
4.4.2 Other features . . . . . . . . . . . . . . . . . . . . . 113
5 Dashboards 117
5.1 Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
5.1.1 Row-based layouts . . . . . . . . . . . . . . . . . . 120
5.1.2 Attributes on sections . . . . . . . . . . . . . . . . . 120
5.1.3 Multiple pages . . . . . . . . . . . . . . . . . . . . . 121
5.1.4 Story boards . . . . . . . . . . . . . . . . . . . . . . 123
5.2 Components . . . . . . . . . . . . . . . . . . . . . . . . . . 124
5.2.1 Value boxes . . . . . . . . . . . . . . . . . . . . . . 125
5.2.2 Gauges . . . . . . . . . . . . . . . . . . . . . . . . . 126
5.2.3 Text annotations . . . . . . . . . . . . . . . . . . . . 128
5.2.4 Navigation bar . . . . . . . . . . . . . . . . . . . . . 130
5.3 Shiny . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
5.3.1 Getting started . . . . . . . . . . . . . . . . . . . . . 132
5.3.2 A Shiny dashboard example . . . . . . . . . . . . . 132
5.3.3 Input sidebar . . . . . . . . . . . . . . . . . . . . . 135
5.3.4 Learning more . . . . . . . . . . . . . . . . . . . . . 135
10 Websites 181
10.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
10.2 The directory structure . . . . . . . . . . . . . . . . . . . . 183
10.3 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 184
10.4 Other site generators . . . . . . . . . . . . . . . . . . . . . 185
10.5 rmarkdown’s site generator . . . . . . . . . . . . . . . . . . 185
10.5.1 A simple example . . . . . . . . . . . . . . . . . . . 186
xii Contents
12 Books 205
12.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
12.2 Project structure . . . . . . . . . . . . . . . . . . . . . . . . 207
12.2.1 Index file . . . . . . . . . . . . . . . . . . . . . . . . 208
12.2.2 Rmd files . . . . . . . . . . . . . . . . . . . . . . . . 208
12.2.3 _bookdown.yml . . . . . . . . . . . . . . . . . . . . 209
12.2.4 _output.yml . . . . . . . . . . . . . . . . . . . . . . 209
12.3 Markdown extensions . . . . . . . . . . . . . . . . . . . . . 209
12.3.1 Number and reference equations . . . . . . . . . . . 210
12.3.2 Theorems and proofs . . . . . . . . . . . . . . . . . 210
12.3.3 Special headers . . . . . . . . . . . . . . . . . . . . 211
12.3.4 Text references . . . . . . . . . . . . . . . . . . . . . 211
12.3.5 Cross referencing . . . . . . . . . . . . . . . . . . . 212
12.4 Output Formats . . . . . . . . . . . . . . . . . . . . . . . . 213
12.4.1 HTML . . . . . . . . . . . . . . . . . . . . . . . . . 213
12.4.2 LaTeX/PDF . . . . . . . . . . . . . . . . . . . . . . 214
12.4.3 E-books . . . . . . . . . . . . . . . . . . . . . . . . 214
12.4.4 A single document . . . . . . . . . . . . . . . . . . 214
12.5 Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
12.5.1 Build the book . . . . . . . . . . . . . . . . . . . . . 215
12.5.2 Preview a chapter . . . . . . . . . . . . . . . . . . . 216
12.5.3 Serve the book . . . . . . . . . . . . . . . . . . . . . 216
Contents xiii
13 Journals 219
13.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
13.2 rticles templates . . . . . . . . . . . . . . . . . . . . . . . . 222
13.3 Using a template . . . . . . . . . . . . . . . . . . . . . . . . 222
13.4 LaTeX content . . . . . . . . . . . . . . . . . . . . . . . . . 224
13.5 Linking with bookdown . . . . . . . . . . . . . . . . . . . 224
13.6 Contributing templates . . . . . . . . . . . . . . . . . . . . 225
Bibliography 299
Index 303
List of Tables
15.1 Possible input types and the associated Shiny functions for pa-
rameterized reports. . . . . . . . . . . . . . . . . . . . . . . 245
xvii
List of Figures
xix
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
xx List of Figures
7.1 Two sample slides created from the xaringan package. . . . . 147
7.2 Separate the current display from the external display. . . . . 156
8.1 Two sample slides created from the revealjs package. . . . . 166
16.1 A graph generated using the sigma.js library and the sigma
package. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
The document format “R Markdown” was first introduced in the knitr pack-
age (Xie, 2015, 2018d) in early 2012. The idea was to embed code chunks (of
R or other languages) in Markdown documents. In fact, knitr supported sev-
eral authoring languages from the beginning in addition to Markdown, in-
cluding LaTeX, HTML, AsciiDoc, reStructuredText, and Textile. Looking back
over the five years, it seems to be fair to say that Markdown has become the
most popular document format, which is what we expected. The simplicity
of Markdown clearly stands out among these document formats.
The rmarkdown package (Allaire et al., 2018c) was first created in early 2014.
During the past four years, it has steadily evolved into a relatively complete
ecosystem for authoring documents, so it is a good time for us to provide a
definitive guide to this ecosystem now. At this point, there are a large number
of tasks that you could do with R Markdown:
xxiii
xxiv Preface
• Create notebooks in which you can directly run code chunks interactively.
Epictetus once said, “Wealth consists not in having great possessions, but in hav-
ing few wants.” The spirit is also reflected in Markdown. If you can control
your preoccupation with pursuing typesetting features, you should be much
more efficient in writing the content and can become a prolific author. It is
entirely possible to succeed with simplicity. Jung Jae-sung was a legendary
badminton player with a remarkably simply playing style: he did not look
like a talented player and was very short compared to other players, so most
of the time you would just see him jump three feet off the ground and smash
like thunder over and over again in the back court until he beats his oppo-
nents.
A few minutes later Jack left the watchman, and made his way
through town toward the cottage in which he lived. And as he
went, his mind busied itself with the idea of the ferry suggested by
Cap’n Crumbie.
Jack Holden was as care-free as any boy of his age in Greenport.
For him, life so far had contained little but healthy sport and
amusement, and the question of earning money had never
concerned him. Nor was it the wish of his father that it should. Yet,
despite his natural light-heartedness, Jack had a level head. The
time would come, and before very long, when he must face the
problem of winning a place for himself in the world. It had been
decided that, if it could be arranged, he was to spend another two
years at High School, after which he would seek a position. But two
years is a long time, and Jack was by no means certain that he
would not have to turn out and become a wage-earner long before
his education was completed. For his father was now a very different
man from the old Samuel Holden. Since the robbery, troubles had
piled themselves on his shoulders somewhat seriously. First had
come the loss of Jack’s mother, from which Mr. Holden had never
really recovered. Then had followed that blow on the head inflicted
by the thief, which had necessitated numerous visits to a costly eye
specialist, in order to preserve his sight. Finally, with his business
taken away from under his feet, he had been in financial straits ever
since. After selling his home to make good the missing money, he
had taken a small cottage on the outskirts of Greenport and gone to
work as a bookkeeper for Garnett and Sayer, the fish-packers. Had
his wife lived, with her indomitable spirit and unending courage—
characteristics which, fortunately, she had bestowed upon her son—
she would have buoyed him up and kept alive his old ambition. But
now his worries told on him, and it was that fact which caused Jack
to wonder sometimes whether his own education would ever be
completed as he would like it to be.
If, he reflected, as he walked home, he could only start that ferry
and so bring a little grist to the mill, it would at least help to relieve
his father of some of his anxiety. But one cannot make bricks without
straw. And he was face to face with the cold fact that he had no boat,
nor any chance of acquiring one. At home, he looked over his sum
total of worldly possessions. There was four dollars and twenty cents
in the savings-bank. He had a nickel and two dimes in his pocket.
Also, he owned a silver watch, of little value, as most of its works
were missing. There was a penknife, which he had bought after
much careful deliberation, and there was—well, little else save
rubbish, worth nothing when it came to a question of raising enough
money to buy a boat suitable for Holden’s Ferry.
“Holden’s Ferry!” Jack repeated aloud, smiling a little at the sound.
The name had an agreeable ring to it. It would be fun. And at the
same time it might be fairly profitable fun.
In the evening, when his father returned, Jack immediately
introduced the subject uppermost in his thoughts.
“Dad,” he began impulsively, “how can I get a boat, twenty feet
long, or something like that—one that will hold ten or a dozen people
and won’t leak more than about ten buckets of water an hour.”
“Eh? What’s that?” asked Mr. Holden, in surprise.
“I’ve got an idea, and I want a boat, Dad,” replied Jack. “I thought
—perhaps—somehow—”
“I wish I could buy you one, my lad,” said Mr. Holden, a trifle
dejectedly, “but you’ll have to wait till my ship comes in.”
“I don’t want it for pleasure—not altogether, that is,” the boy
declared.
“Not for pleasure? Then what on earth— Are you thinking of
setting up in the shipping business?”
Jack chuckled.
“I may do a little freight-carrying,” he said with mock seriousness,
“but the passenger trade is what I was thinking of chiefly.”
“Modest youth! You’ll want to go into steam for that, though,” said
Mr. Holden, jokingly. “It is a pretty tall proposition for a youngster of
your age. Have you fixed on just what ports you are going to trade
at?”
“Only Greenport, Dad. But I’m in earnest.”
Still slightly amused, Mr. Holden stroked his chin and eyed his son
inquiringly.
“Well, what is this wonderful scheme of yours?” he asked.
“I want to run a ferry between Garnett and Sayer’s wharf and the
hotel landing on the Point,” the boy replied. “There is no way of
getting across except by hiring a boat or walking around, or taking a
carriage; and plenty of people would pay a dime to be run across
there in a ferry-boat.”
“Yes, but—”
“Wait a minute, Dad. I’ve had this in my mind all the afternoon.
Cap’n Crumbie tells me there are lots of people who inquire for the
ferry in the summer. He says there never has been one, but that is
no reason why there shouldn’t be one now. Perhaps I wouldn’t make
lots of money at it, but I’m old enough to help you a bit, and I don’t
want to loaf all through vacation, because I know you’ve had worry
enough and that you’re going to have a tough time keeping me in
school until I finish.”
“Well?” observed Samuel Holden, rather vaguely.
“I was wondering,” continued the boy, “whether you could manage
somehow to buy me the sort of boat I’d need. Almost anything would
do that was half-way decent—and clean, too, because summer folk
wouldn’t want to get into her if she wasn’t.”
Mr. Holden shook his head slowly. “I dare say it might work out all
right, Jack,” he said, “and a little more money would come in very
handy, but you’d better get the notion out of your head, son, before
you waste any more time thinking about it. I couldn’t afford to buy
you even a dory, and it’s about six times too far across the water at
that point to row, anyway.”
“All right, Dad,” said Jack, quietly. He realized that there was no
use in asking his father to perform impossibilities. Later in the
evening Mr. Holden noted an expression of quiet determination in the
lad’s face such as he had so often seen in Mrs. Holden’s when,
things not going well, her resourceful brain and stout heart had set
themselves the task of getting affairs back in order.
The next day was Saturday, and shortly after breakfast, there
being no school, Jack and his chum, George Santo, started off on a
hike toward the sand-dunes and salt-flats which lay for miles to the
north of Greenport. This region the boys had made their playground
ever since they were old enough to go about together. It was on the
bold summit of Indian Head, a rocky barrier which for centuries had
kept the encroaching sea at bay, that they had built their first
wigwam out of driftwood, and stood, at the mature ages of nine and
ten respectively, adorned with feathers and armed with spears,
guarding their hunting-grounds from the hated palefaces who never
seemed to approach much nearer than Greenport. From there they
let their eyes wander in imagination over vast herds of buffalo,
moose and antelope grazing peacefully on a far-stretching prairie. At
times, as the hated palefaces all seemed to be fully occupied
elsewhere, phantom palefaces had to blunder upon their hunting-
grounds, and these intruders were hastily despatched or led captive
to the driftwood wigwam, there to be held as hostages. There were
terrific battles up on Indian Head, but somehow or other, whatever
the overwhelming odds with which they were faced, the two lone
braves invariably came out from the encounters unscathed. But the
wigwam was now scattered to the four winds of heaven. The boys
had grown too old for that sort of make-believe; yet their love for the
region of dunes and marsh endured.
On this particular morning they headed over toward the salt-flats
above Cow Creek, and then followed the course of the Sangus River
toward the sea. They must have trudged half a dozen miles by this
circuitous route before Jack, standing on the rippled summit of a
wind-swept dune, drew his companion’s attention to the fact that the
Sangus had changed its sandy course.
“It must have been caused by the flood and the last gale,” he said.
“See, the water has come right across this low bit and—and—say,
George, the old sloop, the Sea-Lark, was lying nearly buried just
along here. I shouldn’t wonder if the river has swept her away now.
Come on, let’s see how the old dear is.”
Ten minutes’ tramping brought them to the place, and each gave a
cry of joy when they saw that the sloop lay exactly as she had lain
for three years. But she had escaped the effects of the recent gale
by a narrow margin only, for the Sangus had swirled over its banks,
eating its way through the sand to a new course, until it now flowed
within twenty feet of the Sea-Lark.
The boys climbed aboard the derelict, and with their legs dangling
over the side, with healthy appetites attacked a parcel of
sandwiches.
“I’m glad she’s still here,” said Jack. “Do you remember when I
was a pirate king last summer and made you walk the plank? We’ve
had lots of fun on this sloop. If she’d been lying a mile or so nearer
Greenport, crowds of kids would have been swarming all over her
and she’d have been broken up.”
George nodded, and poked the last of the sandwiches into his
mouth.
“Talking of boats,” Jack went on, “where do you suppose I could
get one, George?”
“What do you want her for? There’s my dory. You can have that
any time you want.”
“Thanks, George,” Jack replied. “But a dory isn’t just what I do
want.”
Then he explained.
“I don’t know. I guess a boat like that, one you could use for a
ferry, would cost money,” declared the other, when Jack had finished.
“I thought maybe, your father being a boat-builder, you might know
of some way I could manage it,” said Jack. “There’s plenty of time,
because it’s early in the season yet, and maybe I’ll find what I want
somewhere.”
“If you do start the ferry I want to help. May I?” asked George.
“Why not?”
“You’ll be skipper and I’ll be mate,” said George, laughing.
“You mustn’t laugh at the captain—that is, not after you’re properly
appointed mate—” said Jack, “or I’ll order you put in irons. That’s
what they always do. Yes, laugh now, if you like, but wait till I’m your
captain. But why wait? See here, George Santo, weren’t you making
an application to me for a job just now?”
“Yes, sir,” replied George, meekly touching his cap.
“How old are you?” This, brusquely, as befitting a fearsome master
mariner.
“Fifteen, sir.”
“Umph! Pretty young for my class of trade. What’s your rating?”
“Chief mate, sir.”
“Got your certificate?”
“I left it at home, sir.”
“Umph! Very careless of you. Well, you want to sail with me, eh?
What about the compass? Can you box it?”
“I’m a pretty fair boxer, sir.”
“Not that sort of boxing, chump! All right, you’re engaged. Now, Mr.
Mate, laugh at me if you dare!”
Whereupon the mate promptly laughed, and Jack as promptly
hurled him overboard into the raging billows of sand. Jack then
strolled aft and stood for a few moments, measuring the distance
between the embedded sloop and the river.
The mate, clambering aboard again, shouted something which fell
on deaf ears. Again George spoke, and again Jack made no answer.
At last, however, he emerged from his abstraction, and, “Come
here,” he called.
George obeyed, and Jack passed his arm through that of his
friend.
“Now, use your brain,” he said. “How far is it from here to the
stream?”
“Thirty feet,” the other guessed. “Why?”
“Wrong. It’s nearer twenty. And don’t ever ask the captain ‘why’
anything. He’s in supreme command; see? Tell me what is to prevent
us digging the Sea-Lark out of this and getting her afloat.”
“Afloat!” gasped the mate. “Why, you can’t do it! She’s stuck here.”
“Why can’t I do it?”
“Well,” began the mate, dubiously.
“You’ll be disrated if you don’t use more intelligence,” snapped the
skipper. “What are shovels for but to dig with?”
“Yes, but—” began George.
“But what?”
“Well, if you got her afloat she’d only sink. Her timbers will all be
rotten.”
“Show me a rotten timber!” said Jack. “I don’t mean these planks
that have got broken on deck. I mean in the hull. She’s as sound as
a bell. A boat like this would take years and years to rot. She’d need
some calking, I guess, but that’s what I engaged you for, isn’t it?—
while I sit in my deck chair and give orders. George, honestly, I
believe it could be done.”
“But she isn’t yours to float,” parried the mate, “nor to use after you
get her afloat.”
“That’s true,” agreed the skipper, frowning. “But you have got a
way of raising difficulties since I signed you on. Who does she
belong to?”
“She used to belong to Mr. Farnham,” replied George. “He’s a New
York man with pots of money, who lives over on the Point in the
summer. The sloop was in my father’s boat-yard for repairs the
summer before she broke away and got stranded here.”
“Well, do you suppose he wants her? I don’t believe so.”
“Don’t know,” observed George, doubtfully.
“Well, if he does want her, why doesn’t he come and get her? And
what could he use her for? A coal cellar, or what? She’s abandoned,
I tell you.”
“If you took her away from here, which you couldn’t do, anyway,”
observed the younger boy, “you’d be committing ship theft.”
“What’s that?”
“It’s a dreadful offense, worse than piracy. I believe they hang you
for it, or something.”
“I certainly don’t want you to get hanged,” said the captain. “Good
mates are scarce; and they always hang the mate, because he’s
engaged to make himself useful in little ways like that. But it wouldn’t
be ship theft if I wrote a letter to this Mr. Farnham and got his
permission, would it?”
“I suppose not.”
“Of course not. Where does he live?”
“My dad will have his address.”
“Well, don’t forget to ask him for it, and I’ll write. He can only
refuse.”
George, beginning to awake to the possibilities of the plan, cast a
more critical eye over the stranded sloop.
“I wouldn’t be surprised if you were right,” he said at length. “We
might get her into the water.”
“It wouldn’t be exactly easy, because she’s pretty big,” Jack
admitted, “but it would be worth trying, anyway. What a prize if we
got her, though! She’s thirty foot over all, if she’s an inch. And ten—
no, twelve-foot beam. The only thing is, if she did float, we couldn’t
row her very well.”
“There’s bales of junk gear up at our yard,” put in George. “I
suppose her mast got broken off in the gale when she stranded. I
think I could get that fixed all right, though. There’s an old spar that
came out of her when she was refitted. I don’t know why it was taken
out, but it looks all right. We can find an old mainsail and jib
somewhere. Even if they need a bit of patching, they’ll do.”
“The boat is the chief thing,” Jack mused. “The rest will be easy,
once we get her. I’m going to send that letter off to-day. Let’s go
home now and do it.”
Letter-writing was not an occupation which, ordinarily, filled Jack
with joy. But this was not an ordinary occasion. After a first attempt
which he regarded as a failure, the boy produced a missive that was
both frank and polite, and then, feeling that he did not stand a ghost
of a chance of having his request granted, posted it. Later, he and
George walked to the boat-yard, there to consult George’s father,
Tony Santo, on the question of moving the Sea-Lark from her sandy
bed. Tony promised to go down the river and look the sloop over, the
following day, and was as good as his word. Jack and George
accompanied him in his sailing-dory, and to the delight of the boys
the boat-builder declared that there ought not to be a great deal of
difficulty in getting the sloop off, though he cautiously declined either
to have anything to do with such operations or allow his son to,
unless definite permission was received from Mr. Farnham. He
pointed out, however, that the accumulation of sand in the sloop’s
cabin would have to be removed before any attempt could be made
at shifting her. Her companionway door had evidently been open
when she grounded, with the result that in the three years which had
since elapsed the space below deck, a roomy cabin twelve feet by
nine, had been half filled with the fine white sand.
During the next three days the boys, taking a shovel with them,
employed themselves busily at this task until the last of the
undesired ballast was removed. Jack now began to keep an anxious
lookout for the postman. Four days elapsed, and still no reply
arrived. Thursday came, and on returning from school he found an
envelope bearing his name, on the mantel-shelf. His fingers
unsteady with excitement, he tore it open and read:
Dear Sir:
I thought my old sloop must have been broken up by
now. Yes, she is still my property, and if you want her
you are welcome to her, on one condition. If you get
her afloat, you must take me for a sail in her some day.
Yours sincerely,
CHARLES FARNHAM.
CHAPTER III
BACK TO THE WATER
S tuffing the letter into a pocket, Jack reached for his cap, and
hurried out to summon his crew, consisting of George Santo.
“All hands on deck!” he said. “Mr. Mate, we’re going to start work
right away. There are only three weeks of May left, and before long
we’ll have Holden’s Ferry going.”
“Aye, aye, sir,” replied the mate, “if ever we do get her floated.”
“If!” cried Jack. “You talk like a codfish. Of course we’re going to
get her floated! Before we do another thing, though, I’m going to hold
a war council with your dad. He knows best how we can tackle the
job.”
They hurried to the boat-builder’s yard, where Tony was found at
work.
“Mr. Farnham has given me that sloop,” Jack cried as he
approached. “See, here’s his letter.”
Tony’s features developed a broad smile, and he glanced through
the note.
“So you’ll soon be setting off on a journey around the world, or
thereabouts, eh?” he remarked at last, banteringly.
“Well, maybe about half-way, or perhaps as far as Greenport
breakwater,” Jack returned; “but you know, Mr. Santo, we can’t do
much till we get your help.”
“Well, what do you want me to do?” asked Tony good-humoredly,
putting down his hammer.
“I don’t want to bother you too much,” said Jack, “but you said that
if we got stuck you would give us a bit of help.”
“Why, yes, I’ll run over there in the dory some Saturday and help
you to launch her, when you’re ready.”
“Thank you. That will be a tremendous help. Shall we dig a
channel down to the water and float her out that way, or dig the sand
away from her bow—she is lying bow-on toward the river, you know
—and get her out with a winch?”
“I’ll take a winch. That will be easier. I’ll find a place on the
opposite bank of the river where I can moor the winch, and then run
a cable across the water to the sloop. We’ll drag her out when you’ve
done enough spade-work. But mind, you want to get all that sand
clear away from her sides, and make a nice slope up from her bow
so that she won’t stick when the winch begins to haul on her. How
long will that take you? Till next fall?”
“I hope not. We couldn’t very well manage it by next Saturday.
That would only give us two days. But we’ll be ready for the winch
the Saturday after.”
“All right,” replied Tony. “We’ll make that a date.”
To any one less enthusiastic than her proud new owner, the sloop
would not, perhaps, have looked such a priceless possession. There
is something peculiarly desolate about the appearance of a wreck at
any time, and, at least up to the time when the Sangus had again
changed its course, the Sea-Lark had looked even more desolate
than she would otherwise have done, because she was so far from
the river. The water had left her canting over heavily to port, her
stump of mast, a yard long, sticking up. On the port side her deck
was now about level with the sand; her starboard side, raised four or
five feet higher, had formed a barrier against which a solid bank of
the restless sand had settled. Had she been an old boat and needing
paint at the time she came to grief, decay might have left its stamp
upon her in the three years she had lain there; but it so happened
that her oaken beams and hard-pine planking were as sound at the
time of the accident as on the day when they were first put into her,
while the fact that she had received a double coat of paint only two
months before, helped her further to resist the weather. She was not,
therefore, really a wreck, as nothing of any consequence, except the
mast, was broken.
Taking turn and turn about, the two boys worked strenuously, first
removing the sand that had silted up against her starboard side. It
was no light task, for the drift ran the whole length of the sloop, and
the lads’ backs were aching and their limbs weary before they
seemed to have made any impression on it. When the skipper called
a final halt, however, they were well pleased with the result of their
arduous labors. Nevertheless, Jack realized now for the first time
how great was the task he had set himself, and how hopeless would
be his efforts without the kindly assistance of Tony with the winch.
In three days the boys had entirely removed the drift, and then
began to dig down around the sides of the vessel, to release her
from the grip of the sand there. George proved not only a willing but
an extremely useful helper. Though not so tall as his chum, he was
strong, and gave promise of developing into an unusually powerful
man. But it was the spirit with which he threw himself into the task
that Jack appreciated as much as anything. Just before the date of
the appointment with Tony, once when they were resting, perched on
the side of the Sea-Lark, George surveyed the piles of sand which
they had removed in the past week.
“We only want one thing now,” he said thoughtfully, “to make us
both thoroughly happy.”
“What’s that?”
“A peach of a wind-storm, to fill up all the holes we’ve been
digging! If that happened, I don’t believe we’d have the pluck to start
all over again.”
“Don’t suggest such an awful thing,” cried Jack, “or I’ll smite you
with a belaying-pin! By the way, George, I can’t do that.”
“Oh, I am so sorry!” said the other. “Why not?”
“Because there doesn’t seem to be a belaying-pin on board. We’ll
need one or two, won’t we? The skipper always thumps people on
the head with a belaying-pin, particularly the mate. There’s
something about a marlinespike, too, isn’t there? I’m not quite sure
what a marlinespike is, but I think I club you with it when there isn’t a
belaying-pin handy.”
With a deft movement of his body, the mate got behind the skipper
and neatly tipped him overboard into the hole they had so
painstakingly dug; nor was the captain allowed to climb on board
again until the mate had extracted a promise that he would at all
times be treated in a humane manner when they were far out on the
bounding ocean.
During the last of the preparations for Tony’s operations their
spirits rose greatly, for it began to look as though the sloop merely
needed a gentle tug to slide her away from the bed in which she had
so long lain. At school on Friday Jack struggled hard to keep his
attention riveted on his lessons, but it was an effort in which he failed
utterly; for the launching on the morrow of the good ship Sea-Lark
seemed a matter of infinitely greater importance than the problems
that were put before him.
It was late that afternoon when the boy finally declared that all was
ready for the great ceremony. He and his chum had carried out
Tony’s instructions to the letter, even searching about on the bank of
the river for driftwood, which they dragged to the sloop and placed in
position just under her nose. That night Tony was informed of their
readiness for his part in the program, and the boat-builder bade them
be prepared for an early start next day, as it might take until late in
the afternoon to get through.
Not very long after sunrise next day Jack leaped from bed and
looked anxiously out at the window. It seemed as though the Fates
were going to be kind to him, because the weather was perfect for
the day’s operations. The boy was too impatient to eat much
breakfast, and after a hurried meal went round to the Santo boat-
yard, where he found Tony and George already moving the
necessary gear into the sailing-dory—much strong manila rope with
blocks and tackle, a powerful hand-winch, several heavy planks, a
number of rollers, and a bucket of grease. When these were aboard,
the sail was hoisted, and the dory dropped down the creek to the
river. There, as the stream was not over wide, the oars had to be
used, and the dory was rowed some four miles, Tony pulling steadily
all the time, and the boys taking turn and turn about at the other oar.
“It’s hard work against the wind,” said Tony, “but we shall feel the
benefit of it coming back.”
It was only a little after nine o’clock when they reached the spot
where the Sea-Lark lay, and some hours were left before high water
was due. First Tony went ashore and inspected the work the boys
had already done.
“That’s good,” he declared unhesitatingly. “She ought to come off
like a wet fish slides off a plate. Lend a hand with those rollers and
boards in the dory, and we’ll fix her.”
Already Tony seemed to take as keen an interest in the salvage
operations as the boys had done. He soon had everything ready on
that bank of the Sangus, and then crossed the river to moor the
winch in the sand there, so that it would haul without moving. This
was not easily accomplished, for the loose sand gave poor
anchorage. When, however, it was done to his satisfaction, the cable
was run across the water and made fast to the sloop. Tony sent the
boys back to start hauling, while he stood by the Sea-Lark to
“navigate” her. Jack and his chum each seized a crank and began to
tighten the cable. It came easily enough until the drag of the sloop
began. Then they managed a bare-half-turn only. Putting forth every
ounce of their strength, they struggled to start the sloop on her
journey toward the water, but it was beyond them. The Sea-Lark
refused to glide with fairy footsteps down to the river after her long
rest ashore. Tony meanwhile was heaving at the side of the boat to
loosen her keel in the sand, but when he saw the joint efforts of the
boys were unequal to the task, he beckoned them to fetch the dory
across.
“She seems to be glued there,” he declared, “but that glue will
have to come unstuck, if it takes us the whole day to do the trick.
Let’s see if all three of us working at the winch can get her to start.”
Tony rolled up his sleeves, put the boys together at one crank, and
applied his own strength to the other.
“Now, lads,” he said, “give her all you’ve got. Heave!”
There was a back-breaking moment of straining, cracking
muscles.
And then something happened. The Sea-Lark reluctantly began to
move.
Click-click-clickety-click, went the winch.
“Easy, now,” ordered Tony. “Rest a few minutes. She’ll come all
right, and we have plenty of time.”
From that moment the launching of the sloop, though slow, was a
certainty. A dozen times Tony had to make the trip across the river to
adjust the planks and rollers beneath the boat’s keel, but she came
up the slope without mishap.
“My word, she looks big!” Jack exclaimed when he had climbed to
the top and was lumbering along on her side, down to the water’s
edge.
“What did you take her for?—a canoe?” Tony laughed. “She won’t
look as big, though, when she gets into the water. Still, a thirty-foot
sloop is all you two will want to handle in a breeze.”
When their prize was within a foot of the water, Tony went over her
with a calking-iron and mallet, plugging up the worst of the leaky
places with oakum so that she could safely be taken up the river as
far as the boat-yard without danger of sinking on the way. Jack
watched this performance with a critical eye.
“Is she very bad?” he asked with some anxiety.
“Why, no,” replied Tony. “She’s not what you might call seaworthy,
with these seams wide open, but you’re bound to get that. I didn’t
expect to have much trouble with her hull, and I must say that,
considering all things, she’s in pretty fair condition. Just the same, I
guess there’s enough work on her to keep you busy for a week or
so.”
“I don’t care if it takes us all summer! Yes, I do, too,” said Jack. “I
want to get her shipshape in a month or so if possible.”