Advanced R 4 Data Programming and the Cloud: Using PostgreSQL, AWS, and Shiny 2nd Edition Matt Wileyinstant download
Advanced R 4 Data Programming and the Cloud: Using PostgreSQL, AWS, and Shiny 2nd Edition Matt Wileyinstant download
https://ebookmass.com/product/advanced-r-4-data-programming-and-
the-cloud-using-postgresql-aws-and-shiny-2nd-edition-matt-wiley/
https://ebookmass.com/product/beginning-r-4-from-beginner-to-pro-matt-
wiley/
https://ebookmass.com/product/beginning-r-4-from-beginner-to-pro-1st-
edition-matt-wiley/
https://ebookmass.com/product/data-parallel-c-programming-accelerated-
systems-using-c-and-sycl-2nd-edition-james-reinders/
Practical Business Analytics Using R and Python: Solve
Business Problems Using a Data-driven Approach 2nd Edition
Umesh R. Hodeghatta
https://ebookmass.com/product/practical-business-analytics-using-r-
and-python-solve-business-problems-using-a-data-driven-approach-2nd-
edition-umesh-r-hodeghatta/
https://ebookmass.com/product/programming-principles-and-practice-
using-c-2nd-edition-ebook-pdf/
https://ebookmass.com/product/statistics-for-ecologists-using-r-and-
excel-data-collection-exploration/
Advanced R 4 Data
Programming and
the Cloud
Using PostgreSQL, AWS, and Shiny
—
Second Edition
—
Matt Wiley
Joshua F. Wiley
Advanced R 4 Data
Programming and
the Cloud
Using PostgreSQL, AWS, and Shiny
Second Edition
Matt Wiley
Joshua F. Wiley
Advanced R 4 Data Programming and the Cloud: Using PostgreSQL, AWS, and Shiny
iii
Table of Contents
iv
Table of Contents
v
Table of Contents
vi
Table of Contents
Bibliography��������������������������������������������������������������������������������������������������������� 421
Index��������������������������������������������������������������������������������������������������������������������� 425
vii
About the Authors
Matt Wiley leads institutional effectiveness, research,
and assessment at Victoria College, facilitating strategic
and unit planning, data-informed decision making,
and state/regional/federal accountability. As a tenured,
associate professor of mathematics, he won awards in
both mathematics education (California) and student
engagement (Texas). Matt earned degrees in computer
science, business, and pure mathematics from the University
of California and Texas A&M systems.
Outside academia, he coauthors books about the popular R programming language
and was managing partner of a statistical consultancy for almost a decade. He has
programming experience with R, SQL, C++, Ruby, Fortran, and JavaScript.
A programmer, a published author, a mathematician, and a transformational leader,
Matt has always melded his passion for writing with his joy of logical problem solving
and data science. From the boardroom to the classroom, he enjoys finding dynamic ways
to partner with interdisciplinary and diverse teams to make complex ideas and projects
understandable and solvable. Matt enjoys being found online via Twitter @matt math or
http://mattwiley.org/.
ix
About the Authors
x
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
About the Technical Reviewer
Andrew Moskowitz is an analytics and data science
professional in the entertainment industry focused on
understanding user behavior, marketing attribution, and
efficacy and using advanced data science concepts to address
business problems. He earned his PhD in quantitative
psychology at the University of California, Los Angeles, where
he focused on hypothesis testing and mixed-effects models.
xi
Acknowledgments
The authors would like to thank the vibrant R community for their hard work, their
cleverness, their willingness to create and share, and most importantly their kindness
to new learners. One author remembers first getting into programming (in a different
language than R) and very early on trying to use an early incarnation of search engine
to discover what “rtfm” meant. One of R’s best community features is a willingness to
share and not mistake new learner for someone to be “hazed.” This civility is something to
nurture and cherish.
We would also like to thank Andrew for sticking with us for a second edition and a
bleeding-edge version release of R. Thank you, Andrew.
Last, and not least, we would like to thank our family. You continue to support us
through a lot of late evenings, early mornings, and the times in between. Thank you.
xiii
CHAPTER 1
Programming Basics
As with most languages, becoming a power user requires extra understanding of the
underlying structure or rules. Data science through R is powerful, and this chapter
discusses such programming basics including objects, operators, and functions.
Before we dig too deeply into R, some general principles to follow may well be in
order. First, experimentation is good. It is much more powerful to learn hands-on than it
is simply to read. Download the source files that come with this text, and try new things!
Second, it can help quite a bit to become familiar with the ? function. Simply type
? immediately followed by text in your R console to call up help of some kind—for
example, ?sum. We cover more on functions later, but this is too useful to ignore until
that time. Using your favorite search engine is also wise (such as this search string: R sum
na). While memorizing some things may be helpful, much of programming is gaining
skill with effective search.
Finally, just before we dive into the real reason you bought this book, a word of
caution: this is an applied text. Our goal is to get you up and running as quickly as
possible toward some useful skills. A rigorous treatment of most of these topics—even or
especially the ideas in this chapter—is worthwhile, yet beyond the scope of this book.
1
© Matt Wiley and Joshua F. Wiley 2020
M. Wiley and J. F. Wiley, Advanced R 4 Data Programming and the Cloud,
https://doi.org/10.1007/978-1-4842-5973-3_1
Chapter 1 Programming Basics
R 4.0.0 https://cran.r-project.org/
RStudio 1.3.959 https://rstudio.com/products/rstudio/download/
Windows 10 www.microsoft.com/
Java 14 www.oracle.com/technetwork/java/javase/overview/index.html
Amazon Cloud https://aws.amazon.com/
Ubuntu https://ubuntu.com/download
options(
width = 70,
stringsAsFactors = FALSE,
digits = 2)
2
Chapter 1 Programming Basics
Logical objects take on just two values: TRUE or FALSE. Computers are binary machines,
and data often may be recorded and modeled in an all-or-nothing world. These logical
values can be helpful, where TRUE has a value of 1 and FALSE has a value of 0.
As a reminder, # (e.g., the pound sign or hashtag) is an indicator of a code comment.
The words that follow the # are not processed by R and are meant to help the reader:
TRUE ## logical
## [1] TRUE
FALSE ## logical
## [1] FALSE
As you may remember from some quickly muttered comments of your college
algebra professor, there are many types of numbers. Whole numbers, which include
zero as well as negative values, are called integers. In set notation, … ,-2, -1, 0, 1, 2, … ,
these numbers are useful for headcounts or other indexes. In R, integers have a capital L
suffix. If decimal numbers are needed, then double numeric objects are in order. These
are the numbers suited for ratio data types. Complex numbers have useful properties as
well and are understood precisely as you might expect, with an i suffix on the imaginary
portion. R is quite friendly in using all of these numbers, and you simply type in the
desired numbers (remember to add the L or i suffix as needed):
42L ## integer
## [1] 42
## [1] 1.5
## [1] 2+3i
Nominal-level data may be stored via the character class and is designated with
quotation marks:
"a" ## character
## [1] "a"
3
Chapter 1 Programming Basics
Of course, numerical data may have missing values. These missing values are of
the type that the rest of the data in that set would be (we discuss data storage shortly).
Nevertheless, it can be helpful to know how to hand-code logical, integer, double,
complex, or character missing values:
NA ## logical
## [1] NA
NA_integer_ ## integer
## [1] NA
## [1] NA
NA_character_ ## character
## [1] NA
NA_complex_ ## complex
## [1] NA
Factors are a special kind of object, not so useful for general programming, but used
a fair amount in statistics. A factor variable indicates that a variable should be treated
discretely. Factors are stored as integers, with labels to indicate the original value:
factor(1:3)
## [1] 1 2 3
## Levels: 1 2 3
## [1] alice bob charlie
## Levels: alice bob charlie
factor(letters[1:3])
## [1] a b c
## Levels: a b c
4
Chapter 1 Programming Basics
We turn now to data structures, which can store objects of the types we have
discussed (and of course more). A vector is a relatively simple data storage object. A
simple way to create a vector is with the concatenate function c():
## vector
c(1, 2, 3)
## [1] 1 2 3
Just as in mathematics, a scalar is a vector of just length 1. Toward the opposite end
of the continuum, a matrix is a vector with dimensions for both rows and columns.
Notice the way the matrix is populated with the numbers 1–6, counting down each
column:
## [1] 1
## [,1] [,2]
## [1,] 1 4
## [2,] 2 5
## [3,] 3 6
All vectors, be they scalar, vector, or matrix, can have only one data type (e.g., integer,
logical, or complex). If more than one type of data is needed, it may make sense to store
the data in a list. A list is a vector of objects, in which each element of the list may be a
different type. In the following example, we build a list that has character, vector, and
matrix elements:
## vectors and matrices can only have one type of data (e.g., integer,
logical, etc.)
5
Chapter 1 Programming Basics
c(1, 2, 3),
matrix(c(1:6), nrow = 3, ncol = 2)
)
## [[1]]
## [1] "a"
##
## [[2]]
## [1] 1 2 3
##
## [[3]]
## [,1] [,2]
## [1,] 1 4
## [2,] 2 5
## [3,] 3 6
A particular type of list is the data frame, in which each element of the list is identical
in length (although not necessarily in object type). With the underlying building blocks
of the simpler objects, more complex structures evolve. Take a look at the following
instructive examples with output:
## X1.3 X4.6
## 1 1 4
## 2 2 5
## 3 3 6
6
Chapter 1 Programming Basics
## X1.3 letters.1.3.
## 1 1 a
## 2 2 b
## 3 3 c
Because of their superior computational speed, in this text we primarily use data
table objects in R from the data.table package [9]. Data tables are similar to data frames,
yet are designed to be more memory efficient and faster (mostly due to more underlying
C++ code). Even though we recommend data tables, we show some examples with data
frames as well because when working with R, much historical code includes data frames
and indeed data tables inherit many methods from data frames (notice the last line of
code that follows shows TRUE):
##if not yet installed, run the below line of code if needed.
#install.packages("data.table")
library(data.table)
## data.table 1.12.8 using 6 threads (see ?getDTthreads). Latest news:
r-datatable.com
## V1 V2
## 1: 1 4
## 2: 2 5
## 3: 3 6
is.data.frame(dataTable)
## [1] TRUE
7
Chapter 1 Programming Basics
It is worth mentioning at this stage a little bit about the data structure “wars.”
Historically, the predominant way to structure the types of row/column or tabular data
many researchers use was data frames. As data grew in column width and row length,
this base R structure no longer solved everyone’s needs. Grown out of the same SQL
data control mindset as some of the largest databases, the data.table package/library
is (these days) suited to multiple computer cores and efficient memory operations and
uses more-efficient-than-R languages under the hood. For the largest data sets and for
those who have any background in SQL or other programming languages, data tables
are hugely effective and intuitive. Not all folks first coming to R have a programming
background (and indeed that is a very good thing). A competing data structure, the
tibble, is part of what is called the tidyverse (a portmanteau of tidy and universe). Tibbles,
like data tables, are also data frames at heart, yet they are improved. In the authors’
opinion, while not yet quite as fast as tables, tibbles have a more new-user-friendly
style or language syntax. They’re beloved by a large part of the R community and are an
important part of modern R. In practice, data tables are still faster and can often achieve
tasks your authors find most common in fewer lines of code. Both these newer structures
have their strengths, and both have their place in the R universe (and indeed Chapters 7
and 8 focus on data tables, yet time is given to tibbles in Chapter 9). All the same, this text
will primarily use data tables.
Having explored several types of objects, we turn our attention to ways of
manipulating those objects with operators and functions.
8
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Exploring the Variety of Random
Documents with Different Content
expedition, that he had no time for writing; and he valued no
Colonel Macleod to
words of commendation, which were spoken with regard to his
General Lawson.
services, so much as those referring to the chief engineer and
himself, which formed part of a despatch written by General
Hutchinson, the successor of Sir R. Abercromby:—“The skill and
‘London Gazette,’ 22
perseverance of those two officers have overcome difficulties which
October, 1801.
at first appeared almost insurmountable.”
The arrival of a Turkish division, 6000 strong, to support him, on the 3rd April, 1801,
induced General Hutchinson, who succeeded Sir R. Abercromby in the command, to
carry the war farther up the Nile, instead of waiting before Alexandria. He commenced
with some detached operations: Rosetta surrendered on the 8th, and Fort St. Julian,
after a bombardment, on the 19th. “On the 18th April a mortar
Browne’s ‘England’s
battery, erected against Fort St. Julian, under the direction of
Artillerymen.’
Captains Lemoine and Duncan, fired some shells with remarkable
accuracy: one of them pitched on the centre of the roof, and tore
away the flagstaff and colours, which the French never dared to erect again.”
The great events of the campaign were the surrender of Cairo on the 28th June, 1801,
and of Alexandria on the 2nd September. It was during the march on Cairo that the
ingenuity and endurance of the Royal Artillery were most severely tried. Other writers
have borne testimony—in glowing, but not exaggerated terms—to the gallantry of the
other arms of the service in this campaign; and it must not be assumed that the
necessary allusions to a particular corps in a work like this imply any assertion of
superiority; such conduct would be at once unjust, and subversive of the main purpose
of this history. There are regiments, the very mention of whose names brings
instinctively to the hearer’s memory the brave story of Egypt; but, where all were brave,
the special professional duties of Artillerymen obtained for those, who served in that
capacity, opportunities of displaying energy and ingenuity which were denied to others.
There have been campaigns where the exertions of the Infantry have dwarfed those of
the other arms; there have been occasions—sung by poets, and boasted of with just
pride by all Englishmen—when the honour of England was entrusted to her Cavalry, and
was brought back with redoubled lustre; it is, therefore, in no spirit of depreciation of the
other arms that the services of the Artillery are especially pointed out, during a campaign
where the hardest work was not in battle, and in a work which hopes to hand down to
their successors the merits of those who, in Egypt, were responsible for their Regiment’s
reputation. It is with such a hope that words like the following, referring to the siege of
Alexandria, are reproduced:—“The proceedings against Alexandria
Stewart’s
showed to what a pitch of perfection the British Artillery had
‘Highlanders of
Scotland.’ arrived. The battery on the Greenhill opened at six o’clock on the
morning of the 26th August, and before mid-day the enemy were
completely silenced, their batteries destroyed, and their guns withdrawn. On the west of
Alexandria, the tower of Marabout was bombarded from a battery commanded by
Captain Curry,9 of the Royal Artillery. The first shot struck the tower, four feet from the
ground; every succeeding shot struck the same spot; and in this manner he continued,
never missing his mark, till a large hole was in a manner completely bored through,
when the building fell, and, filling up the surrounding ditch, the place was instantly
surrendered.”
At the surrender of Cairo no fewer than 13,754 French were present, and were allowed
to evacuate Egypt; and at Alexandria, where General Menou, the French Commander,
was stationed,—11,000 French soldiers, exclusive of civilians,
Cust.
surrendered to the English. In a campaign which lasted only from
March to September, the power of the French in Egypt, and even
their presence, disappeared. Prior to the capitulation of General Menou, he made a
strong effort to drive the English from before Alexandria. This took place on the 22nd
August, and in the general orders issued after the engagement the following words
appeared:—“The brunt of the day fell on the Artillery, under the command of Major
Cookson, and the advance corps, who used every exertion, and showed much discipline.”
It is also mentioned by a writer often quoted in these pages,
Browne, author of
whose industry becomes more and more apparent the more his
‘England’s
Artillerymen.’ work is studied, that “the celerity with which the guns at the siege
of Alexandria had been brought up was a remarkable instance of
zeal, as they had to be carried over almost inaccessible rocks.”
Two events occurred during the campaign, which deserve mention. A contingent of
troops arrived from India under Sir David Baird, including some of the East India
Company’s Artillery. The first instalment arrived on the 10th June, and was present at
the surrender of Cairo by the French; and Sir David, with the main body, arrived in
sufficient time to witness the successful termination of the siege of Alexandria, and with
it the conclusion of the war.
The second event involves some explanation. In 1798 a detachment of the Royal Artillery
was ordered to Turkey to assist in the instruction and organization of the Turkish
Artillery, and in the strengthening of their fortifications. The officer in command was
Brigadier-General Koehler, who had as a subaltern attracted attention during the great
Siege of Gibraltar, and who had been almost continuously employed on the Staff of the
army since that time. The Artillery officers who accompanied him were Majors Hope and
Fead, Captain Martin Leake, and Assistant-Surgeon Wittman. The duties of these officers,
as far as can be learned from the correspondence which is extant, were of a somewhat
motley order,—embracing artillery, engineering, archæology, and military organization.
Their travels in Turkey, Greece, Syria, and Egypt were very extensive; and if we may
judge from a quaint manuscript in the Royal Artillery Record Office, describing a journey
made by them to Jerusalem, they must have travelled as royal personages. General
Koehler died on the 29th December, 1800, of a malignant fever, which had carried off his
wife and many of his detachment; and the regret and positive grief, which were felt by
English and Turks alike, were strongly expressed in Major Hope’s
Major Hope, R.A., to
reports to England. After his death, Major Hope, with the
D. A. General,
January 1801. remainder of the detachment, accompanied the Grand Vizier and
the Turkish contingent, which went to Egypt to swell the English
forces, and earned well-deserved praise before Cairo, where the union between them
and the latter took place. Major Hope’s abilities as an Artilleryman received favourable
mention from the Grand Vizier. After the conclusion of the campaign, Captain Leake
obtained special employment in the Turkish dominions, and that he attained no mean
position in the scientific and literary world may be gathered from the following obituary
notice:—“On the 6th January, 1860, Colonel Leake passed from us,
Obituary notice of
after a short and sudden illness. His intellect never weakened; his
Lieut.-Col. W. M.
Leake, R.A., in energies scarcely relaxed, notwithstanding the weight of eighty-
Address of the three years. The Greek minister, at his own desire, followed him to
President of the the grave, expressing thereby the gratitude of his country to one
Royal Geographical who had spared no effort on behalf of the Greek nationality, and
Society, May 1860.
had done so much by his works towards elucidating the
remarkable features of the land of Greece, and the scenes of her
glorious history. In him we have lost not only a scholar and an antiquary, but one other
link (when so few survived) that connected us to the politics, the literature, and the
society of the foregone generation.”
On the 16th November, 1801, an order was issued for the withdrawal of the companies
from Egypt, under which Captain Beevor’s company of the 3rd Battalion, and Captain
Cookson’s, Major Sprowle’s, and Captain Wood’s of the 5th, returned to England; and
Major Borthwick’s, Captain Lemoine’s, and Captain Adye’s proceeded to Gibraltar. Major
Borthwick remained in command of his company during the war, although, by the
records of the 2nd Battalion, to which it belonged, Captain Mudge had been posted to it
some time previously, an appointment which must have been subsequently cancelled,
doubtless owing to his being employed by Government on the Trigonometrical Survey of
Great Britain. In this occupation he was engaged during the greater part of his life, and
his admirable conduct of the survey procured for him numerous literary and scientific
distinctions.
Among the officers of artillery who received special mention for their services in Egypt,
besides General Lawson, were Major Cookson, who, in addition to
Kane’s List.
receiving high praise in general orders and despatches, was
appointed, on the 29th October, 1801, commandant of the ancient
Pharos Castle and of all the Artillery in Egypt, and was presented with a gold medal by
the Grand Vizier; Captains Lemoine, A. Duncan, and S. G. Adye. Major Thompson, who
had received brevet rank of Colonel during the war, died of wounds received on the 9th
May, 1801, near Ramanieh; and it should be mentioned that General Lawson himself was
severely wounded at the battle of Alexandria.
By General orders of 31st October and 1st November, 1803, the officers, non-
commissioned officers, and men of the various companies which had served in Egypt
were permitted to wear the “Sphynx,” with the word “Egypt” on their regimental caps;
but the distinction was a personal one, and not to be perpetuated in the companies. In
regiments of the Line the distinction is perpetuated by emblazonment on their colours.
Although, however, the decoration itself was but personal, the traditions of the deeds
which it commemorated are the inheritance of the batteries, whose predecessors fought
under the shadow of the Pyramids. Let them treasure the memories of gallantry and of
difficulties overcome, and in the hours of their own toils and dangers let them
“remember Egypt.”
S O many important events will demand detailed notice presently, that this chapter
must be confined to a bare statement of facts, necessary to keep the chain of the
Regimental history complete. The circumstances, under which the Royal Irish
Artillery was incorporated as the 7th Battalion of the Regiment,
Vol. i. pp. 163 & 417.
have already been mentioned. No sooner had the amalgamation
taken place, than a questionable step was taken by the authorities
at the Ordnance: they ordered the 5th Battalion to proceed to Ireland, and relieve the
7th; and the six companies of the 7th Battalion, which were serving in their native land,
were promptly shipped off to the West Indies to relieve the companies of the 1st, 2nd,
and 4th Battalions. This instant use of the new battalion to garrison an unpleasant
station can hardly have had a conciliatory effect; and doubtless the sudden and
unpleasant change of quarters awakened occasional doubts as to the value of the Union
—in a military point of view,—if not occasional mental growlings on the subject of
“Justice to Ireland,” among those who had to exchange the pleasures of Dublin for the
disadvantages of the tropics. Be this as it may, in 1802 the new battalion was ordered to
the West Indies.
The arrangements of the Board for the reliefs of the companies at this time reveal a very
distinct attempt to secure, as far as possible, that companies of the same battalion
should serve on the same station. For example, it was decided that, in 1803, the whole
of the companies at Gibraltar should belong to the 6th Battalion; that the 1st and 2nd
Battalions should be collected in England; the 5th in Ireland; and that the detached
commands, and the wants of Canada should be supplied by the 3rd and 4th Battalions.
The scheme was marred by an occasional company of a battalion, which it was hoped to
concentrate, being found to be at the Cape of Good Hope, or Ceylon; but the effort was
honestly made, and with the best intentions. That it utterly failed during the tempest of
war, which was so soon and so long to rage, was not the fault of those who hoped to
produce a very different state of affairs; but the result of inevitable causes. The
American War had proved the inconvenience of a battalion’s head-quarters being on the
scene of hostilities: the lesson was accepted, and the various head-quarters were located
at Woolwich; and therefore, the fact having been once admitted that the necessary
control could be exercised, at a distance, over an individual company, all ideas of
symmetry had to yield to necessity: and whencesoever a company could be most readily
obtained, from that station it was taken, irrespective of the battalion to which it
belonged. The test of a system frequently does not occur until the system must vanish
before it; and this was the case in the wars between 1807 and 1815, which proved most
satisfactorily that the official dreams of the Ordnance in 1802 and 1803 were not worth
the paper on which they were written. Out of the web which was so honestly spun, the
company, in time of war, made its inevitable escape, and asserted yet again its right to
be called the Artillery unit.
On the signing of the Treaty of Peace, at Amiens, on the 27th March, 1802, immediate
reductions were ordered in the military forces of England. In the Royal Artillery they took
the form of reductions in the strength of the companies; and the following was the
scheme, approved by the Master General, on the recommendation of Colonel Macleod.
The short-lived amity between the French and English Governments did not admit of the
reductions being altogether carried out; but it is interesting to see how they were
proposed to be conducted.
Proposal agreed to
on 7 Dec. 1801.
Non-
—— Sergeants. Corporals. Bombardiers. Gunners. Drumers. Total.
effectives.
Present
strength
40 40 70 980 30 30 1,190
of one
Battalion
Proposed
30 30 60 700 30 30 880
strength
To be
10 10 10 280 ·· ·· 310
reduced
Total
reduction
70 70 70 1,960 ·· ·· 2,170
in seven
Battalions
N.B. Of the above number of men to be reduced, there were about 680 men from
the Militia, who were entitled to their discharge.
This reduction left the proportion of non-commissioned officers to gunners the same as
before, viz. 1 to 6. During the American War, it had been as 1 to 5; after the peace of
1783, it fell to 1 to 7; and during the earlier wars of the French Revolution it rose to 1 to
6.
The strength of the Corps of Gunner-drivers in 1802 was as follows: Seven troops, each
consisting of—
1 Captain-Commissary.
2 Lieutenants-Commissary.
2 Staff-Sergeants.
4 Sergeants.
6 First Corporals.
6 Second Corporals.
6 Farriers.
3 Smiths.
4 Collar-Makers.
4 Wheelers.
150 Gunner-drivers.
25 Riding Horses.
Staff.— 1 Quartermaster.
1 Veterinary Surgeon.
The gunner-drivers attached to, and doing duty with the Horse Brigade, are not included
above, being by a Royal Warrant of 1st September, 1801, mustered and paid with the
Troops to which they were attached. These were in number 336. There were also 18
quartermaster-commissaries awaiting absorption, having been struck off the
establishment on reduction. The number of horses belonging to the Corps of Gunner-
drivers at this time included 2300 draught-horses, and 178 riding-horses.
Chevrons were put on the arms of non-commissioned officers, according to the rules of
the Army generally, instead of epaulettes, in the year 1802. The Royal Artillery Band was
increased from 10 to 21 in the same year.
Two allusions to methods of discharging men at this time, which are found in the official
correspondence, speak for themselves. The first is an order to discharge a man for his
bad conduct, and to hand him over to the press-gang: and the second is a reply to a
request from Lord Napier, that a man might be discharged, to enable him to support his
family; and is as follows: “Charles Copeland; 5 feet 11 inches in
Colonel Macleod to
Colonel Hadden, 9
height; a wife and two children. It is observed that he would have
Jan. 1802. been discharged, if he had been lucky enough to have three.”
Note.—By inadvertence, it was omitted to be noticed in the first volume of this work,
in giving the list of Masters-General of the Ordnance, that Lord Chatham held that
appointment from 18th June, 1801, to 14th February, 1806, and was reappointed on
4th April, 1807, the date given in vol. i. as that of his first appointment. Lord Moira
was Master-General from 14th February, 1806, to 4th April, 1807.
CHAPTER VIII.
The Eighth Battalion.
T HE Treaty of Amiens was not destined to be carried out in its entirety by the nations
concerned. Napoleon’s hostility to the English could not be concealed; and the
evacuation of Malta, Alexandria, and the Cape of Good Hope, which had been
commenced by the latter, in accordance with the terms of the Treaty, was never fully
completed. On the 13th March, 1803, Lord Whitworth, the English Ambassador, was
publicly insulted by Napoleon at the Tuileries; and on the 6th May he quitted Paris. The
recommencement of hostilities with France was aggravated by another insurrection in
Ireland, which was happily quelled with little difficulty. But the general state of affairs
was so serious that an augmentation of the military forces in England became urgently
necessary, as well as renewed activity on the part of the fleet. The Government received
warm and cordial support from the people, both as a body and individually. Lord
Chatham, then Master-General of the Ordnance, received on the
Mr. J. Bagot, London,
18th July a letter from a Mr. John Bagot, to the following effect:
to Lord Chatham,
dated 11 July, 1803. —“Being anxious in the present awful crisis to come forward in any
line that my services can be of use to my King and country, I beg
leave to offer, for the consideration of your Lordship, to raise a Battalion of Artillery, of
300 men, for the war or such further period as may be necessary, and on such terms as
your Lordship or His Majesty’s Government may direct....”
The state of recruiting in England was, however, so favourable, that the Master-General
was not compelled to have recourse to private enterprise to obtain the necessary
augmentations to the Regiment. The number of non-commissioned officers and men in
the Horse Brigade and Marching Battalions of the Royal Artillery on
Mem. to Master-
the 1st January, 1803, was 6777; on the 1st June, notwithstanding
Genl. from Colonel
the loss of 306 men by death or discharge, the total had increased
Macleod, 13 Aug.
1803. to 7119; and in two months more, it stood at 7439, besides 131
recruits in the country districts, not yet posted. The Corps of
Gunner-drivers had increased in the same period by 1109 men. It was therefore resolved
to increase the Regiment by another battalion, the 8th, and the first intimation of this
resolution is found in a private letter from the Deputy Adjutant-
Colonel Macleod to
General. “It is at last, I believe, determined,” he wrote, “to increase
Lieut.-Colonel
Willington, dated 7 the Artillery, even under all the disadvantages of a deficiency in
Sept. 1803. officers. The cadets are doubled; and the winter may do a good
deal for us: in the mean time we take twenty of the most forward.
Our companies will only have two 1st Lieutenants: there will be hardly a 2nd Lieutenant
upon the establishment.”
On the 13th September seven companies were formed, and on the 6th December, three
additional companies were added to the battalion. The establishment of each company
was as follows:—
Lieutenant Kane to
R. H. Crew, Esq.
1 Captain.
1 Captain-Lieutenant.
2 First Lieutenants.
1 Second Lieutenant.
4 Sergeants.
4 Corporals.
8 Bombardiers (and 3 non-effective, i.e. paper men).
97 Gunners.
3 Drummers.
Many of the men for the 8th Battalion were obtained by calling for volunteers from the
Army of Reserve; and although every obstacle was thrown in the way of this method of
obtaining recruits, by the officers commanding the Reserve Battalions, which were this
year called out for service, very many excellent men were thus obtained.
It is unfortunate that the Battalion record-book of the 8th Battalion has been lost since
1859, the year when Battalion Head-quarters were abolished, because, although these
books were, as a rule, very meagre in the information they afforded, they nevertheless
supplied facts which it would have been difficult to obtain elsewhere without great
labour. That labour, in the case of the 8th Battalion, has been
Lieut. J. Ritchie,
Staff-Officer, Coast
readily undertaken by an officer at Head-quarters, and to his
Brigade, R.A. industry the reader is indebted for the following tables.
11th Battalion
Records.
T HIS Battalion of the Royal Artillery was formed in an eventful year. Whether we
regard it from a political or a purely military point of view, the year 1806 had an
important influence on those which followed it.
The previous year, the year of Austerlitz, had witnessed the collapse of Pitt’s coalition
against Napoleon, and the consequent isolation of England. But it was also the year of
Trafalgar; and left England still mistress of the seas.
With 1806 came the Battle of Jena, Napoleon’s triumphal entry into Berlin, and the issue
of his famous declaration against English commerce, which, if obeyed to the letter, would
have put England virtually in a state of blockade. It was a critical year for a country
whose commerce was her very life-blood; and in this very year, those who had so long
steered the ship of the State, William Pitt and Charles James Fox, were removed by
death. But the country took up the gauntlet thrown down by Napoleon, and from this
year conducted with sternness and determination a war which, from being one of
resistance, became one for existence as well.
It was a year, too, which should be remembered fondly in the annals of the British Army
—the year of the Battle of Maida, described in the last chapter, where the gallantry of
the British troops against Napoleon’s tried legions obtained a victory, which had a moral
influence both in England and on the Continent, which is perhaps rarely realised now.
Grasping the importance of the situation, and greatly assisted by the ease of obtaining
recruits, the Board of Ordnance resolved on an augmentation of the Royal Artillery to the
extent of yet another battalion. The strength of the Regiment, and its periodical increase
and decrease, are ascertainable from a return which used to be furnished annually to the
Board, called the “Wear and Tear of the Regiment for the year ending,” &c. From this
return it would appear that during the year 1805, the number of gunner-recruits who
joined the Horse Artillery and Marching Battalions was no less than 2574. But the wear
and tear by death, transfer, desertion, &c., during the same period was 1017, so that the
net increase was 1557; the Regiment rising from 10,203, at which it stood on 1st
January, 1805, to 11,760, its strength on the 31st December in the same year. During
the same period the Corps of Royal Artillery Drivers, and Drivers attached to the Horse
Brigade, had received 489 recruits, and, allowing for the wear and tear during the year,
had increased from 4897 to 4986 of all ranks, excluding officers.
It is hardly possible that this large increase to the establishment had been allowed by
the Board without a motive; and it may indeed be assumed with tolerable certainty that
the formation of the 9th Battalion had been to some extent contemplated during
Napoleon’s successes in 1805. This impression is confirmed by reference to the returns
for the year 1806, which show that the increase to the Regiment during that year was
only half what had taken place during the year preceding.
The increase which had been permitted during the year 1805 proved to be greater than
was necessary for the wants of the new Battalion; and the establishment of the
Regiment was found on the 1st May, 1806, to have been exceeded by over 400 men.
This excess, however, was soon swallowed up by the year’s wear and tear, which in 1806
amounted to 874 men.
The promotions consequent on the formation of the new Battalion were gazetted on
22nd May, 1806, and Major-General Thomas Blomefield was appointed Colonel-
Commandant. The record-book of the Battalion, like that of the 8th, has been lost since
the introduction of the Brigade system. It was permitted to accompany the head-
quarters of the 9th Brigade, and during their frequent changes of station it has been
mislaid—offering another argument, if one were needed, in favour of the centralization
of all military records. As in the case of the 8th Battalion, so in the
Lieut. J. Ritchie,
present instance the Regiment is indebted to an officer at Head-
Staff-Officer Coast
Brigade, R.A. quarters for the following facts connected with the companies prior
to 1850. Their present designations, and the stations in which they
served, have been given, and the succession of Captains down to a certain date. The
war services of some companies will be found mentioned in the succeeding narrative,
and the tables will be completed, should the compilation of the separate work on the
Crimea be at some future time accomplished.
List of Captains down to 1850. Stations on which the Company has served.
1806 Captain J. S. Robison 1806 Woolwich.
1808 Captain J. T. Cowper. 1807 Ireland.
1819 Captain W. D. Nicolls. 1816 Jamaica.
1833 Captain G. Durnford. 1825 Woolwich.
1842 Captain R. B. Rawnsley. 1827 Ireland.
1845 Captain H. G. Teesdale. 1833 Woolwich.
1846 Captain R. M. Poulden. 1833 Gibraltar.
1846 Captain A. J. Taylor. 1842 Woolwich.
1850 Captain T. Elwyn. 1843 Ireland.
1846 Woolwich.
1847 Barbadoes.
No. 2 COMPANY, 9th BATTALION,
Now “E” BATTERY, 8th BRIGADE, R.A.
List of Captains who have commanded down List of Stations where the Company has
to 1846. served down to 1850.
1806 Captain J. Smith. 1806 Woolwich.
1807 Captain J. W. Tobin. 1807 Ireland.
1814 Captain S. Bolton. 1815 Holland and France.
1815 Captain W. Clibborn. 1816 Woolwich.
1819 Captain C. Wilkinson. 1822 Barbadoes.
1825 Captain T. Dyneley. 1828 Woolwich.
1825 Captain J. Darby. 1831 Scotland.
1827 Captain C. Cruttenden. 1835 Woolwich.
1827 Captain P. W. Walker. 1836 Gibraltar.
1840 Captain R. Clarke. 1845 Woolwich.
1846 Captain C. V. Cockburn. 1847 Guernsey.
1849 Woolwich.
1850 Jamaica.
Captains who have commanded the Stations on which the Company has served
Company to 1846. to 1848.
1806 Captain H. Crawford. 1806 Woolwich.
1807 Captain W. Lloyd. 1808 Canterbury.
1808 Captain N. W. Oliver. 1809 Walcheren.
1810 Captain S. Maxwell. 1809 Canterbury.
1812 Captain J. Hawker. 1813 Holland.
1814 Captain C. G. Alms. 1815 France.
1819 Captain P. J. Hughes. 1816 Woolwich.
1825 Captain W. B. Dundas. 1819 Ireland.
1833 Captain C. Cruttenden. 1825 Jamaica.
1838 Captain G. T. Rowland. 1830 Woolwich.
1846 Captain G. Innes. 1833 Newcastle, Leeds, &c.
1838 Woolwich.
1840 Jamaica.
1846 Woolwich.
1848 Ireland.
Captains who have commanded the Stations on which the Company has served
Company to 1846. to 1849.
1806 Captain J. May. 1806 Woolwich.
1807 Captain J. W. Tobin. 1809 Chatham.
1807 Captain J. W. Smith. 1809 Chatham.
1809 Captain H. Stone. 1809 Walcheren.
1813 Captain J. Michell. 1809 Chatham.
1830 Captain M. Louis. 1811 Portsmouth.
1837 Captain C. Otway. 1812 Peninsula and France.
1837 Captain R. Palmer. 1814 America.
1846 Captain W. H. Forbes. 1815 Holland and France.
1816 Woolwich.
1819 Weedon.
1824 Woolwich.
1824 Jamaica.
1830 Woolwich.
1834 Ireland
1840 Woolwich.
1841 Mauritius.
1849 Woolwich.
Names of Captains who commanded it down Stations on which the Battery has served
to 1848. down to 1849.
1806 Captain B. Macdonald. 1806 Woolwich.
1806 Captain H. F. Holcombe. 1808 Chatham.
1807 Captain G. Massey. 1809 Walcheren.
1812 Captain J. E. Jones. 1809 Canterbury.
1828 Captain J. E. G. Parker. 1810 Dover.
1833 Captain R. Heron. 1814 Halifax, N.S.
1841 Captain R. L. Garstin. 1826 Woolwich.
1848 Captain C. R. Wynne. 1829 Ireland.
1834 Gibraltar.
1843 Woolwich.
1845 Devonport.
1848 Woolwich.
1849 Corfu.
Names of Captains who commanded it down Stations on which the Company served
to 1850. down to 1846.
1806 Captain J. P. Cockburn. 1806 Woolwich.
1806 Captain J. F. Ogilvie. 1808 Chatham.
1807 Captain J. S. Sinclair. 1809 Portsmouth.
1808 Captain T. J. Forbes. 1810 Ireland.
1823 Captain C. Mosse. 1817 Barbadoes.
1831 Captain W. Greene. 1827 Woolwich.
1834 Captain C. Dalton. 1829 Devonport.
1834 Captain J. C. Petley. 1833 Woolwich.
1837 Captain A. Wright. 1834 Jamaica.
1840 Captain F. Warde. 1841 Woolwich.
1842 Captain B. Cuppage. 1843 Devonport.
1849 Captain T. de Winton. 1845 Woolwich.
1850 Captain A. T. Phillpotts. 1846 Gibraltar.
ebookmasss.com