100% found this document useful (1 vote)
44 views

First Course in Statistical Programming With R 2nd Edition Braun - The 2025 ebook edition is available with updated content

The document provides information about the second edition of 'A First Course in Statistical Programming with R' by W. John Braun and Duncan J. Murdoch, which emphasizes programming principles and includes real R code for data analysis. It covers various topics such as statistical graphics, simulation, computational linear algebra, and numerical optimization, making it a comprehensive guide for beginners in R programming. Additionally, it highlights the integration of RStudio and updates in the R community since the first edition.

Uploaded by

itaouitrautt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
44 views

First Course in Statistical Programming With R 2nd Edition Braun - The 2025 ebook edition is available with updated content

The document provides information about the second edition of 'A First Course in Statistical Programming with R' by W. John Braun and Duncan J. Murdoch, which emphasizes programming principles and includes real R code for data analysis. It covers various topics such as statistical graphics, simulation, computational linear algebra, and numerical optimization, making it a comprehensive guide for beginners in R programming. Additionally, it highlights the integration of RStudio and updates in the R community since the first edition.

Uploaded by

itaouitrautt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

First Course in Statistical Programming With R 2nd


Edition Braun

https://ebookmeta.com/product/first-course-in-statistical-
programming-with-r-2nd-edition-braun/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Asymptotic Statistical Inference A Basic Course Using R


Shailaja Deshmukh

https://ebookmeta.com/product/asymptotic-statistical-inference-a-
basic-course-using-r-shailaja-deshmukh/

ebookmeta.com

Bayesian Networks With Examples in R Chapman Hall CRC


Texts in Statistical Science 2nd Edition Scutari

https://ebookmeta.com/product/bayesian-networks-with-examples-in-r-
chapman-hall-crc-texts-in-statistical-science-2nd-edition-scutari/

ebookmeta.com

Functional Programming in R 4: Advanced Statistical


Programming for Data Science, Analysis, and Finance -
Second Edition Thomas Mailund
https://ebookmeta.com/product/functional-programming-in-r-4-advanced-
statistical-programming-for-data-science-analysis-and-finance-second-
edition-thomas-mailund/
ebookmeta.com

The Cruel Birth of Bangladesh Memoirs of an American


Diplomat 2002nd Edition Archer K Blood

https://ebookmeta.com/product/the-cruel-birth-of-bangladesh-memoirs-
of-an-american-diplomat-2002nd-edition-archer-k-blood/

ebookmeta.com
Sin Demons 06.0 - Hell on Earth 1st Edition Mila Young

https://ebookmeta.com/product/sin-demons-06-0-hell-on-earth-1st-
edition-mila-young/

ebookmeta.com

Statistics: The Art and Science of Learning from Data


[RENTAL EDITION] Coll

https://ebookmeta.com/product/statistics-the-art-and-science-of-
learning-from-data-rental-edition-coll/

ebookmeta.com

A Geek Girl s Guide to Electronics and the Internet of


Things 1st Edition Audrey O'Shea

https://ebookmeta.com/product/a-geek-girl-s-guide-to-electronics-and-
the-internet-of-things-1st-edition-audrey-oshea/

ebookmeta.com

Berlitz Pocket Guide Israel Travel Guide eBook 2nd


Edition Berlitz

https://ebookmeta.com/product/berlitz-pocket-guide-israel-travel-
guide-ebook-2nd-edition-berlitz/

ebookmeta.com

This Long Thread Women of Color on Craft Community and


Connection 1st Edition Jen Hewett

https://ebookmeta.com/product/this-long-thread-women-of-color-on-
craft-community-and-connection-1st-edition-jen-hewett/

ebookmeta.com
Dad Bod Secret Prince Dad Bod Series Men Built for Comfort
1st Edition Andrea Marie

https://ebookmeta.com/product/dad-bod-secret-prince-dad-bod-series-
men-built-for-comfort-1st-edition-andrea-marie/

ebookmeta.com
A First Course in Statistical
Programming with R
This new, color edition of Braun and Murdoch’s bestselling textbook
integrates use of the RStudio platform and adds discussion of newer
graphics systems, extensive exploration of Markov chain Monte
Carlo, expert advice on common error messages, motivating
applications of matrix decompositions, and numerous new examples
and exercises.

This is the only introduction you’ll need to start programming in R,


the computing standard for analyzing data. Co-written by an R Core
Team member and an established R author, this book comes with
real R code that complies with the standards of the language. Unlike
other introductory books on the R system, this book emphasizes
programming, including the principles that apply to most computing
languages, and techniques used to develop more complex projects.
Solutions, datasets, and any errata are available from the book’s
website. The many examples, all from real applications, make it
particularly useful for anyone working in practical data analysis.

W. John Braun is Deputy Director of the Canadian Statistical Sciences


Institute. He is also Professor and Head of the Departments of
Computer Science, Physics, Mathematics and Statistics at the
University of British Columbia Okanagan. His research interests are
in the modeling of environmental phenomena, such as wildfire, as
well as statistical education, particularly as it relates to the R
programming language.
Duncan J. Murdoch is a member of the R Core Team of developers,
and is co-president of the R Foundation. He is one of the developers
of the rgl package for 3D visualization in R, and has also developed
numerous other R packages. He is also a professor in the
Department of Statistical and Actuarial Sciences at the University of
Western Ontario.
A First Course in Statistical
Programming with R

Second Edition

W. John Braun and Duncan J. Murdoch


32 Avenue of the Americas, New York NY 10013
Cambridge University Press is part of the University of Cambridge.
It furthers the University’s mission by disseminating knowledge in
the pursuit of education, learning, and research at the highest
international levels of excellence.
www.cambridge.org
Information on this title: www.cambridge.org/9781107576469
W. John Braun and Duncan J. Murdoch 2007, 2016
This publication is in copyright. Subject to statutory exception and to
the provisions of relevant collective licensing agreements, no
reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2007
Second edition 2016
Printed in the United States of America by Sheridan Books, Inc.
A catalogue record for this publication is available from the British
Library.
ISBN 978-1-107-57646-9 Hardback
Additional resources for this publication at
www.cambridge.org/9781107576469.
Cambridge University Press has no responsibility for the persistence
or accuracy of URLs for external or third-party Internet Web sites
referred to in this publication and does not guarantee that any
content on such Web sites is, or will remain, accurate or appropriate.
Contents
Preface to the second edition
Preface to the first edition

1 Getting started
1.1 What is statistical programming?
1.2 Outline of this book
1.3 The R package
1.4 Why use a command line?
1.5 Font conventions
1.6 Installation of R and RStudio
1.7 Getting started in RStudio
1.8 Going further

2 Introduction to the R language


2.1 First steps
2.2 Basic features of R
2.3 Vectors in R
2.4 Data storage in R
2.5 Packages, libraries, and repositories
2.6 Getting help
2.7 Logical vectors and relational operators
2.8 Data frames and lists
2.9 Data input and output

3 Programming statistical graphics


3.1 High level plots
3.2 Choosing a high level graphic
3.3 Low level graphics functions
3.4 Other graphics systems
4 Programming with R
4.1 Flow control
4.2 Managing complexity through functions
4.3 The replicate() function
4.4 Miscellaneous programming tips
4.5 Some general programming guidelines
4.6 Debugging and maintenance
4.7 Efficient programming

5 Simulation
5.1 Monte Carlo simulation
5.2 Generation of pseudorandom numbers
5.3 Simulation of other random variables
5.4 Multivariate random number generation
5.5 Markov chain simulation
5.6 Monte Carlo integration
5.7 Advanced simulation methods

6 Computational linear algebra


6.1 Vectors and matrices in R
6.2 Matrix multiplication and inversion
6.3 Eigenvalues and eigenvectors
6.4 Other matrix decompositions
6.5 Other matrix operations

7 Numerical optimization
7.1 The golden section search method
7.2 Newton–Raphson
7.3 The Nelder–Mead simplex method
7.4 Built-in functions
7.5 Linear programming

Appendix Review of random variables and distributions

Index
Expanded contents
Preface to the second edition
Preface to the first edition

1 Getting started
1.1 What is statistical programming?
1.2 Outline of this book
1.3 The R package
1.4 Why use a command line?
1.5 Font conventions
1.6 Installation of R and RStudio
1.7 Getting started in RStudio
1.8 Going further

2 Introduction to the R language


2.1 First steps
2.1.1 R can be used as a calculator
2.1.2 Named storage
2.1.3 Quitting R
2.2 Basic features of R
2.2.1 Functions
2.2.2 R is case-sensitive
2.2.3 Listing the objects in the workspace
2.3 Vectors in R
2.3.1 Numeric vectors
2.3.2 Extracting elements from vectors
2.3.3 Vector arithmetic
2.3.4 Simple patterned vectors
2.3.5 Vectors with random patterns
2.3.6 Character vectors
2.3.7 Factors
2.3.8 More on extracting elements from vectors
2.3.9 Matrices and arrays
2.4 Data storage in R
2.4.1 Approximate storage of numbers
2.4.2 Exact storage of numbers
2.4.3 Dates and times
2.4.4 Missing values and other special values
2.5 Packages, libraries, and repositories
2.6 Getting help
2.6.1 Built-in help pages
2.6.2 Built-in examples
2.6.3 Finding help when you don’t know the function name
2.6.4 Some built-in graphics functions
2.6.5 Some elementary built-in functions
2.7 Logical vectors and relational operators
2.7.1 Boolean algebra
2.7.2 Logical operations in R
2.7.3 Relational operators
2.8 Data frames and lists
2.8.1 Extracting data frame elements and subsets
2.8.2 Taking random samples from populations
2.8.3 Constructing data frames
2.8.4 Data frames can have non-numeric columns
2.8.5 Lists
2.9 Data input and output
2.9.1 Changing directories
2.9.2 dump() and source()
2.9.3 Redirecting R output
2.9.4 Saving and retrieving image files
2.9.5 The read.table function

3 Programming statistical graphics


3.1 High level plots
3.1.1 Bar charts and dot charts
3.1.2 Pie charts
3.1.3 Histograms
3.1.4 Box plots
3.1.5 Scatterplots
3.1.6 Plotting data from data frames
3.1.7 QQ plots
3.2 Choosing a high level graphic
3.3 Low level graphics functions
3.3.1 The plotting region and margins
3.3.2 Adding to plots
3.3.3 Adjusting axis tick labels
3.3.4 Setting graphical parameters
3.4 Other graphics systems
3.4.1 The ggplot2 package
3.4.2 The lattice package
3.4.3 The grid package
3.4.4 Interactive graphics

4 Programming with R
4.1 Flow control
4.1.1 The for() loop
4.1.2 The if() statement
4.1.3 The while() loop
4.1.4 Newton’s method for root finding
4.1.5 The repeat loop, and the break and next statements
4.2 Managing complexity through functions
4.2.1 What are functions?
4.2.2 Scope of variables
4.2.3 Returning multiple objects
4.2.4 Using S3 classes to control printing
4.3 The replicate() function
4.4 Miscellaneous programming tips
4.4.1 Always edit code in the editor, not in the console
4.4.2 Documentation using #
4.4.3 Neatness counts!
4.5 Some general programming guidelines
4.5.1 Top-down design
4.6 Debugging and maintenance
4.6.1 Recognizing that a bug exists
4.6.2 Make the bug reproducible
4.6.3 Identify the cause of the bug
4.6.4 Fixing errors and testing
4.6.5 Look for similar errors elsewhere
4.6.6 Debugging in RStudio
4.6.7 The browser(), debug(), and debugonce() functions
4.7 Efficient programming
4.7.1 Learn your tools
4.7.2 Use efficient algorithms
4.7.3 Measure the time your program takes
4.7.4 Be willing to use different tools
4.7.5 Optimize with care

5 Simulation
5.1 Monte Carlo simulation
5.2 Generation of pseudorandom numbers
5.3 Simulation of other random variables
5.3.1 Bernoulli random variables
5.3.2 Binomial random variables
5.3.3 Poisson random variables
5.3.4 Exponential random numbers
5.3.5 Normal random variables
5.3.6 All built-in distributions
5.4 Multivariate random number generation
5.5 Markov chain simulation
5.6 Monte Carlo integration
5.7 Advanced simulation methods
5.7.1 Rejection sampling
5.7.2 Importance sampling

6 Computational linear algebra


6.1 Vectors and matrices in R
6.1.1 Constructing matrix objects
6.1.2 Accessing matrix elements; row and column names
6.1.3 Matrix properties
6.1.4 Triangular matrices
6.1.5 Matrix arithmetic
6.2 Matrix multiplication and inversion
6.2.1 Matrix inversion
6.2.2 The LU decomposition
6.2.3 Matrix inversion in R
6.2.4 Solving linear systems
6.3 Eigenvalues and eigenvectors
6.4 Other matrix decompositions
6.4.1 The singular value decomposition of a matrix
6.4.2 The Choleski decomposition of a positive definite matrix
6.4.3 The QR decomposition of a matrix
6.5 Other matrix operations
6.5.1 Kronecker products
6.5.2 apply()

7 Numerical optimization
7.1 The golden section search method
7.2 Newton–Raphson
7.3 The Nelder–Mead simplex method
7.4 Built-in functions
7.5 Linear programming
7.5.1 Solving linear programming problems in R
7.5.2 Maximization and other kinds of constraints
7.5.3 Special situations
7.5.4 Unrestricted variables
7.5.5 Integer programming
7.5.6 Alternatives to lp()
7.5.7 Quadratic programming

Appendix Review of random variables and distributions

Index
Preface to the second edition

A lot of things have happened in the R community since we wrote


the first edition of this text. Millions of new users have started to use
R, and it is now the premier platform for data analytics. (In fact, the
term “data analytics” hardly existed when we wrote the first edition.)

RStudio, a cross-platform integrated development environment for


R, has had a large influence on the increase in popularity. In this
edition we recommend RStudio as the platform for most new users,
and have integrated simple RStudio instructions into the text. In
fact, we have used RStudio and the knitr package in putting
together the manuscript.

We have also added numerous examples and exercises, and


cleaned up existing ones when they were unclear. Chapter 2
(Introduction to the R language) has had extensive revision and
reorganization. We have added short discussions of newer graphics
systems to Chapter 3 (Programming statistical graphics). Reference
material on some common error messages has been added to
Chapter 4 (Programming with R), and a list of pseudorandom
number generators as well as a more extensive discussion of Markov
chain Monte Carlo is new in Chapter 5 (Simulation). In Chapter 6
(Computational linear algebra), some applications have been added
to give students a better idea of why some of the matrix
decompositions are so important.

Once again we have a lot of people to thank. Many students have


used the first edition, and we are grateful for their comments and
criticisms. Some anonymous reviewers also provided some helpful
suggestions and pointers so that we could make improvements to
the text. We hope our readers find this new edition as interesting
and educational as we think it is.

W. John Braun
Duncan Murdoch

November, 2015
Preface to the first edition

This text began as notes for a course in statistical computing for


second year actuarial and statistical students at the University of
Western Ontario. Both authors are interested in statistical
computing, both as support for our other research and for its own
sake. However, we have found that our students were not learning
the right sort of programming basics before they took our classes. At
every level from undergraduate through Ph.D., we found that the
students were not able to produce simple, reliable programs; that
they didn’t understand enough about numerical computation to
understand how rounding error could influence their results, and
that they didn’t know how to begin a difficult computational project.

We looked into service courses from other departments, but we


found that they emphasized languages and concepts that our
students would not use again. Our students need to be comfortable
with simple programming so that they can put together a simulation
of a stochastic model; they also need to know enough about
numerical analysis so that they can do numerical computations
reliably. We were unable to find this mix in an existing course, so we
designed our own.

We chose to base this text on R. R is an open source computing


package which has seen a huge growth in popularity in the last few
years. Being open source, it is easily obtainable by students and
economical to install in our computing lab. One of us (Murdoch) is a
member of the core R development team, and the other (Braun) is a
co-author of a book on data analysis using R. These facts made it
easy for us to choose R, but we are both strong believers in the idea
that there are certain universals of programming, and in this text we
try to emphasize those: it is not a manual about programming in R,
it is a course in statistical programming that uses R.

Students starting this course are not assumed to have any


programming experience or advanced statistical knowledge. They
should be familiar with university-level calculus, and should have had
exposure to a course in introductory probability, though that could
be taken concurrently: the probabilistic concepts start in Chapter 5.
(We include a concise appendix reviewing the probabilistic material.)
We include some advanced topics in simulation, linear algebra, and
optimization that an instructor may choose to skip in a one-semester
course offering.

We have a lot of people to thank for their help in writing this book.
The students in Statistical Sciences 259b have provided motivation
and feedback, Lutong Zhou drafted several figures, Kristy Alexander,
Yiwen Diao, Qiang Fu, and Yu Han went over the exercises and
wrote up detailed solutions, and Diana Gillooly of Cambridge
University Press, Professor Brian Ripley of Oxford University, and
some anonymous reviewers all provided helpful suggestions. And of
course, this book could not exist without R, and R would be far less
valuable without the contributions of the worldwide R community.

W. John Braun
Duncan Murdoch

February, 2007
1
Getting started

Welcome to the world of statistical programming. This book contains


a lot of specific advice about the hows and whys of the subject. We
start in this chapter by giving you an idea of what statistical
programming is all about. We will also tell you what to expect as you
proceed through the rest of the book. The chapter will finish with
some instructions about how to download and install R, the software
package and language on which we base our programming examples,
and RStudio, an “integrated development environment” (or “IDE”) for
R.

1.1 What is statistical programming?

Computer programming involves controlling computers, telling them


what calculations to do, what to display, etc. Statistical programming
is harder to define. One definition might be that it’s the kind of
computer programming statisticians do – but statisticians do all sorts
of programming. Another would be that it’s the kind of programming
one does when one is doing statistics: but again, statistics involves a
wide variety of computing tasks.

For example, statisticians are concerned with collecting and


analyzing data, and some statisticians would be involved in setting up
connections between computers and laboratory instruments: but we
would not call that statistical programming. Statisticians often
oversee data entry from questionnaires, and may set up programs to
aid in detecting data entry errors. That is statistical programming, but
it is quite specialized, and beyond the scope of this book.
Statistical programming involves doing computations to aid in
statistical analysis. For example, data must be summarized and
displayed. Models must be fit to data, and the results displayed.
These tasks can be done in a number of different computer
applications: Microsoft Excel, SAS, SPSS, S-PLUS, R, Stata, etc. Using
these applications is certainly statistical computing, and usually
involves statistical programming, but it is not the focus of this book.
In this book our aim is to provide a foundation for an understanding
of how those applications work: what are the calculations they do,
and how could you do them yourself?

Since graphs play an important role in statistical analysis, drawing


graphics of one-, two-, or higher-dimensional data is an aspect of
statistical programming.

An important part of statistical programming is stochastic


simulation. Digital computers are naturally very good at exact,
reproducible computations, but the real world is full of randomness.
In stochastic simulation we program a computer to act as though it is
producing random results, even though, if we knew enough, the
results would be exactly predictable.

Statistical programming is closely related to other forms of


numerical programming. It involves optimization, and approximation
of mathematical functions. Computational linear algebra plays a
central role. There is less emphasis on differential equations than in
physics or applied mathematics (though this is slowly changing). We
tend to place more of an emphasis on the results and less on the
analysis of the algorithms than in computer science.

1.2 Outline of this book


This book is an introduction to statistical programming. We will start
with basic programming: how to tell a computer what to do. We do
this using the open source R statistical package, so we will teach you
R, but we will try not to just teach you R. We will emphasize those
things that are common to many computing platforms.

Statisticians need to display data. We will show you how to


construct statistical graphics. In doing this, we will learn a little bit
about human vision, and how it motivates our choice of display.

In our introduction to programming, we will show how to control


the flow of execution of a program. For example, we might wish to
do repeated calculations as long as the input consists of positive
integers, but then stop when an input value hits 0. Programming a
computer requires basic logic, and we will touch on Boolean algebra,
a formal way to manipulate logical statements. The best programs
are thought through carefully before being implemented, and we will
discuss how to break down complex problems into simple parts.
When we are discussing programming, we will spend quite a lot of
time discussing how to get it right: how to be sure that the computer
program is calculating what you want it to calculate.

One distinguishing characteristic of statistical programming is that it


is concerned with randomness: random errors in data, and models
that include stochastic components. We will discuss methods for
simulating random values with specified characteristics, and show
how random simulations are useful in a variety of problems.

Many statistical procedures are based on linear models. While


discussion of linear regression and other linear models is beyond the
scope of this book, we do discuss some of the background linear
algebra, and how the computations it involves can be carried out. We
also discuss the general problem of numerical optimization: finding
the values which make a function as large or as small as possible.
Each chapter has a number of exercises which are at varying
degrees of difficulty. Solutions to selected exercises can be found on
the web at www.statprogr.science.

1.3 The R package

This book uses R, which is an open source package for statistical


computing. “Open source” has a number of different meanings; here
the important one is that R is freely available, and its users are free
to see how it is written, and to improve it. R is based on the
computer language S, developed by John Chambers and others at
Bell Laboratories in 1976. In 1993 Robert Gentleman and Ross Ihaka
at the University of Auckland wanted to experiment with the
language, so they developed an implementation, and named it R.
They made it open source in 1995, and thousands of people around
the world have contributed to its development.

1.4 Why use a command line?

The R system is mainly command-driven, with the user typing in text


and asking R to execute it. Nowadays most programs use interactive
graphical user interfaces (menus, touchscreens, etc.) instead. So why
did we choose such an old-fashioned way of doing things?

Menu-based interfaces are very convenient when applied to a


limited set of commands, from a few to one or two hundred.
However, a command-line interface is open ended. As we will show in
this book, if you want to program a computer to do something that
no one has done before, you can easily do it by breaking down the
task into the parts that make it up, and then building up a program to
carry it out. This may be possible in some menu-driven interfaces,
but it is much easier in a command-driven interface.
Moreover, learning how to use one command-line interface will give
you skills that carry over to others, and may even give you some
insight into how a menu-driven interface is implemented. As
statisticians, it is our belief that your goal should be understanding,
and learning how to program at a command line will give you that at
a fundamental level. Learning to use a menu-based program makes
you dependent on the particular organization of that program.

There is no question that command-line interfaces require greater


knowledge on the part of the user – you need to remember what to
type to achieve a particular outcome. Fortunately, there is help. We
recommend that you use the RStudio integrated development
environment (IDE). IDEs were first developed in the 1970s to help
programmers: they allow you to edit your program, to search for
help, and to run it; when your first attempt doesn’t work, they offer
support for diagnosing and fixing errors. RStudio is an IDE for R
programming, first released in 2011. It is produced by a Boston
company named RStudio, and is available for free use.

1.5 Font conventions

This book describes how to do computations in R. As we will see in


the next chapter, this requires that the user types input, and R
responds with text or graphs as output. To indicate the difference, we
have typeset the user input and R output in a gray box. The output is
prefixed with ##. For example

In most cases other than this one and certain exercises, we will
show the actual response from R corresponding to the preceding
input.1
There are also situations where the code is purely illustrative and is
not meant to be executed. (Many of those are not correct R code at
all; others illustrate the syntax of R code in a general way.) In these
situations we have typeset the code examples in an upright
typewriter font. For example,

f( some arguments )

1.6 Installation of R and RStudio

R can be downloaded from http://cloud.r-project.org. Most users


should download and install a binary version. This is a version that
has been translated (by compilers) into machine language for
execution on a particular type of computer with a particular operating
system. R is designed to be very portable: it will run on Microsoft
Windows, Linux, Solaris, Mac OSX, and other operating systems, but
different binary versions are required for each. In this book most of
what we do would be the same on any system, but when we write
system-specific instructions, we will assume that readers are using
Microsoft Windows.

Installation on Microsoft Windows is straightforward. A binary


version is available for Windows Vista or above from the web page
http://cloud.r-project.org/bin/windows/base. Download the “setup
program,” a file with a name like R-3.2.5-win.exe. Clicking on this file
will start an almost automatic installation of the R system. Though it
is possible to customize the installation, the default responses will
lead to a satisfactory installation in most situations, particularly for
beginning users.

One of the default settings of the installation procedure is to create


an R icon on your computer’s desktop.
You should also install RStudio, after you have installed R. As with
R, there are separate versions for different computing platforms, but
they all look and act similarly. You should download the “Open Source
Edition” of “RStudio Desktop” from www.rstudio.com/, and follow the
instructions to install it on your computer.

1.7 Getting started in RStudio

Once you have installed R and RStudio, you will be ready to start
statistical programming. We’ll start with a quick tour of RStudio, and
introduce more detail in later chapters.

When you are working in RStudio, you’ll see a display something


like Figure 1.1. (The first time you start it, you won’t see all the
content that is in the figure.) The display includes four panes. The
top left pane is the Source Pane, or editor. You will type your program
(or other document) there. The bottom left pane is called the Console
Pane. This is where you communicate with R. You can type directly
into this pane, but it is usually better to work within the editor pane,
because that way you can easily correct mistakes and try again.
Fig. 1.1 A typical RStudio display.

The two right-hand panes contain a variety of tabs. In the figure,


the top pane is showing the Workspace, and the bottom pane is
showing a plot; we’ll discuss these and the other tabs in later
chapters. For now, you just need to know the following points:

You should do most of your work in the editor, but you can
occasionally type in the console.
The console pane displays what R is doing.
All of the panes can be resized and repositioned, so sometimes it
may appear that you’ve lost one, but there’s no need to worry:
just find the header of the pane and click there with your mouse,
and the pane will reappear. If the pane is there but the content
isn’t what you want, try clicking on the tabs at the top.

1.8 Going further


This book introduces statistical programming with R, but doesn’t
come close to covering everything. Here are some further resources.

There are many textbooks that will teach you more about
statistics. We recommend Data Analysis and Graphics Using R:
An Example-Based Approach by Maindonald and Braun and
Introductory Statistics with R by Dalgaard for an introductory
level presentation, and the classic Modern Applied Statistics with
S by Venables and Ripley for more advanced material. Advanced
R by Wickham gives more detail about programming in R.
There are many tools that use R in preparing printed documents.
We particularly like knitr, which you can read about online at
http://yihui.name/knitr or in the book Dynamic Documents
with R and knitr by Xie. It provides a very rich system; for a
simple subset (useful to write your assignments for class!), take
a look at R Markdown (http://rmarkdown.rstudio.com/).
R can also be used to prepare interactive web pages. The Shiny
system displays output from R based on prepared scripts that are
controlled in a browser. The user doesn’t need to install R, but he
or she can see R output. You can see an example and read more
about Shiny at http://shiny.rstudio.com.

1 We have used the knitr package so that R itself is computing the


output. The computations in the text were done with R version 3.2.2
(2015-08-14).
2
Introduction to the R language

Having installed the R and RStudio systems, you are now ready to begin to learn
the art of statistical programming. The first step is to learn the syntax of the
language that you will be programming in; you need to know the rules of the
language. This chapter will give you an introduction to the syntax of R. Most of
what we discuss here relates to what you would type into the R console or into
the RStudio script window.

2.1 First steps

Having opened R or RStudio, you may begin entering and executing commands,
usually interactively. Normally, you will use the Source Pane to type in your
commands, but you may occasionally use the Console Pane directly. The greater-
than sign (>) is the prompt symbol which appears in the Console Pane.

2.1.1 R can be used as a calculator

Anything that can be computed on a pocket calculator can be computed at the R


prompt. The basic operations are + (add), - (subtract), * (multiply), and /
(divide). For example, try

Upon pressing the Enter key (or CTRL-Enter), the result of the above division
operation, 42, appears in the Console Pane, preceded by the command you
executed, and prefixed by the number 1 in square brackets:
The [1] indicates that this is the first (and in this case only) result from the
command. Many commands return multiple values, and each line of results will
be labeled to aid the user in deciphering the output. For example, the sequence
of integers from 17 to 58 may be displayed as follows:

The first line starts with the first return value, so it is labeled [1]; the second
line starts with the 23rd, so it is labeled [23].

Everything that you type after a # sign is assumed to be a comment and is


ignored by R.

Note the use of parentheses in the examples above. Parentheses are used to
ensure that the operations (in this case, :, *, and +) are carried out in the order
that we desire. In the first case, parentheses were necessary to obtain the result
we wanted to see. The following shows what happens when the parentheses are
omitted:

If you are surprised by this result, it would be a good exercise to break the
calculation down into the three separate operations in order to determine exactly
what R is doing.
The parentheses were not required in (7:10) + pi. We used them anyway, for
two reasons. First, they can help others read and understand the code more
quickly. Second, although R follows strict and consistent rules regarding order of
operations, we believe it is too easy for a user to forget one or more of these
rules. Therefore, we recommend using parentheses whenever you are unsure (or
even in cases where you think you may be right).

R can also be used to compute powers with the operator. For example,

Modular arithmetic is also available. For example, you can compute the
remainder after division of 31 by 7, i.e. :

and the integer part of a fraction as

We can confirm that 31 is the sum of its remainder plus seven times the
integer part of the fraction:

2.1.2 Named storage


R has a workspace known as the global environment that can be used to store
the results of calculations, and many other types of objects. For a first example,
suppose we would like to store the result of the calculation 1.0025^30 for future
use. (This might arise from a compound interest calculation based on an interest
rate of 0.25% per year and a 30-year term.) We will assign this value to an
object called interest.30. To do this, we type

We tell R to make the assignment using an arrow that points to the left,
created with the less-than sign (<) and the hyphen (-). R also supports using the
equals sign (=) in place of the arrow in most circumstances, but we recommend
using the arrow, as it makes clear that we are requesting an action (i.e. an
assignment), rather than stating a relation (i.e. that interest.30 is equal to
1.0025^30), or making a permanent definition. Note that when you run this
statement, no output appears: R has done what we asked, and is waiting for us
to ask for something else.

You can see the results of this assignment by typing the name of our new
object at the prompt:

Think of this as just another calculation: R is calculating the result of the


expression interest.30, and printing it. You can also use interest.30 in further
calculations if you wish. For example, you can calculate the bank balance after
30 years at 0.25% annual interest, if you start with an initial balance of $3000:

Example 2.1
An individual wishes to take out a loan, today, of P at a monthly interest rate i.
The loan is to be paid back in n monthly installments of size R, beginning one
month from now. The problem is to calculate R.

Equating the present value P to the future (discounted) value of the n monthly
payments R, we have

or

Summing this geometric series and simplifying, we obtain

This is the formula for the present value of an annuity. We can find R, given P, n,
and i as

In R, we define variables as follows: principal to hold the value of P, intRate


to hold the interest rate, and n to hold the number of payments. We will assign
the resulting payment value to an object called payment.

Of course, we need some numerical values to work with, so we will suppose


that the loan amount is $1500, the interest rate is 1% and the number of
payments is 10. The required code is then
For this particular loan, the monthly payments are $158.37.

2.1.3 Quitting R

To quit your R session, run

or choose Quit RStudio... from the File menu. You will then be asked whether
to save an image of the current workspace, or not, or to cancel. The workspace
image contains a record of the computations you’ve done, and may contain
some saved results. Hitting the Cancel option allows you to continue your current
R session. We rarely save the current workspace image, but occasionally find it
convenient to do so.

Note what happens if you omit the parentheses () when attempting to quit:

This has happened because q is a function that is used to tell R to quit. Typing
q by itself tells R to show us the (not very pleasant-looking) contents of the
function q. By typing q(), we are telling R to call the function q. The action of
this function is to quit R. Everything that R does is done through calls to
functions, though sometimes those calls are hidden (as when we click on
menus), or very basic (as when we call the multiplication function to multiply 14
times 3).

Recording your work

Rather than saving the workspace, we prefer to keep a record of the commands
we entered, so that we can reproduce the workspace at a later date. The easiest
way to do this is in RStudio is to enter commands in the Source Pane, and run
them from there. At the end of a session, save the final script for a permanent
record of your work. In other systems a text editor and some form of cut and
paste serve the same purpose.

Exercises
1 Calculate the remainder after dividing 31079 into 170166719.
2 Calculate the interest earned after 5 years on an investment of $2000,
assuming an interest rate of 3% compounded annually.
3 Using one line of R code, calculate the interest earned on an investment
of $2000, assuming an interest rate of 3% compounded annually, for
terms of 1, 2, , 30 years.
4 Calculate the monthly payment required for a loan of $200,000, at a
monthly interest rate of 0.003, based on 300 monthly payments,
starting in one month’s time.
5 Use R to calculate the area of a circle with radius 7 cm.
6 Using one line of R code, calculate the respective areas of the circles
having radii .
7 In the expression 48:(14*3), are the brackets really necessary? What
happens when you type 48:14*3?
8 Do you think there is a difference between 48:14^2 and 48:(14^2)? Try
both calculations. Using one line of code, how would you obtain the
squares of the numbers ?

2.2 Basic features of R

2.2.1 Functions

Most of the work in R is done through functions. For example, we saw that to
quit R we can type q(). This tells R to call the function named q. The
parentheses surround the argument list, which in this case contains nothing: we
just want R to quit, and do not need to tell it how.
We also saw that q is defined as

This shows that q is a function that has three arguments: save, status, and
runLast. Each of those has a default value: "default", 0, and TRUE, respectively.
What happens when we execute q() is that R calls the q function with the
arguments set to their default values.

If we want to change the default values, we specify them when we call the
function. Arguments are identified in the call by their position, or by specifying
the name explicitly. For example, both

tell R to call q with the first argument set to "no", i.e. to quit without saving the
workspace. If we had given two arguments without names, they would apply to
save and status. If we want to accept the defaults of the early parameters but
change later ones, we give the name when calling the function, e.g.

or use commas to mark the missing arguments, e.g.

Note that we must use = to set arguments. If we had written


q(runLast <- FALSE) it would be interpreted quite differently from
q(runLast = FALSE). The arrow says to put the value FALSE into a variable named
runLast. We then pass the result of that action (which is the value FALSE) as the
first argument of q(). Since save is the first argument, it will act like
q(save = FALSE), which is probably not what we wanted.
It is a good idea to use named arguments when calling a function which has
many arguments or when using uncommon arguments, because it reduces the
risk of specifying the wrong argument, and makes your code easier to read.

2.2.2 R is case-sensitive

Consider this:

Now try

The function mean() is built into R. R considers MEAN to be a different function,


because it is case-sensitive: m is different from M.

2.2.3 Listing the objects in the workspace

The calculations in the previous sections led to the creation of several simple R
objects. These objects are stored in the current R workspace. A list of all objects
in the current workspace can be printed to the screen using the objects()
function:

A synonym for objects() is ls().


Remember that if we quit our R session without saving the workspace image,
then these objects will disappear. If we save the workspace image, then the
workspace will be restored at our next R session.1

2.3 Vectors in R

2.3.1 Numeric vectors

A numeric vector is a list of numbers. The c() function is used to collect things
together into a vector. We can type

Again, we can assign this to a named object:

To see the contents of x, simply type

The : symbol can be used to create sequences of increasing (or decreasing)


values. For example,

Vectors can be joined together (i.e. concatenated) with the c function. For
example, note what happens when we type
Here is another example of the use of the c() function:

If you type this in the R console (not in the RStudio Source Pane), R will
prompt you with a + sign for the second line of input. RStudio doesn’t add the
prompt, but it will indent the second line. In both cases you are being told that
the first line is incomplete: you have an open parenthesis which must be
followed by a closing parenthesis in order to complete the command.

We can append numbers5to20 to the end of some.numbers, and then append


the decreasing sequence from 4 to 1:

Remember that the numbers printed in square brackets give the index of the
element immediately to the right. Among other things, this helps us to identify
the 22nd element of a.mess as 89: just count across from the 17th element, 67.

2.3.2 Extracting elements from vectors

A nicer way to display the 22nd element of a.mess is to use square brackets to
extract just that element:
We can extract more than one element at a time. For example, the third,
sixth, and seventh elements of a.mess are

To get the third through seventh elements of numbers5to20, type

Negative indices can be used to avoid certain elements. For example, we can
select all but the second and tenth elements of numbers5to20 as follows:

The third through 11th elements of numbers5to20 can be avoided as follows:

Using a zero index returns nothing. This is not something that one would
usually type, but it may be useful in more complicated expressions. For example,
recall that x contains the vector so that

Do not mix positive and negative indices. To see what happens, observe
Exploring the Variety of Random
Documents with Different Content
FOOTNOTES:
[40] Omitted by Author.—A.B.L.
[41] This paper appears, from an independent source ['The Siege
and Fall of Port Arthur,' by Major-General Kostenko, President of
the Military Court of Port Arthur during the siege], to have been
the copy of a telegram to the Tsar which Stössel had despatched
to the Tsar before this council meeting was held. According to
Kostenko this telegram was: 'We cannot hold out more than a few
days; am taking measures to prevent a street massacre'; and in
his opinion Stössel did not read it out at this council meeting after
the feeling of the members had been so strongly declared against
surrender, because he was afraid of being arrested for having
sent it.—A.B.L.

CHAPTER XLI
THE FALL OF FORTIFICATION NO. 3—THE FAILURE OF THE
DEFENCE AND MEDICAL ORGANIZATIONS
The garrison no longer showed the same steadiness that it had
shown in the many desperate fights in the beginning of December.
This was certainly owing to the example of Fort Chi-kuan-shan. The
men's spirits seemed to have gone, and it was too late for the
officers to stop the hæmorrhage from the moral wounds caused by
Fock. A passionate desire for life was everywhere noticeable, and
any attempt to persuade the men that it was their duty to die was
now useless.
Early in the morning of the 31st Gorbatovsky was summoned by
Fock to confer with him. The latter was, as usual, dilating on the
splendid qualities of the men, and the pity it was to make them
suffer needlessly, when a great pillar of smoke suddenly shot up
from Fortification No. 3, followed by a tremendous explosion.
'I must go back, sir, and I will return at once and let you know what
has happened.'
'Yes, come back as soon as you can.'
Gorbatovsky then went off. Without waiting for a report from him,
Fock there and then, in the presence of Captain Rodionoff, of the
Engineers, wrote out his orders for the abandonment of Fortification
No. 3, and sent them off by (I think) a sailor. There was no
reference, no word to the Commandant, or even to Stössel.
Comment is unnecessary; such action speaks for itself.
What had happened is best seen by reference to the diary:
'December 31.—About 6 a.m. General Gorbatovsky was summoned
by General Fock to the third line of defences to confer. At 9 a.m.
three successive explosions took place in Fortification No. 3. After a
few minutes a telephone message came in from the work to say that
the enemy had exploded two charges in the corners of one of the
faces. At the moment when the garrison, led by its commanding
officer, Captain Spredovy, dashed out of the quarters in the gorge
casemate, in order to get out into the interior of the place before the
Japanese could seize the parapet, a third charge was fired, which
had been laid in the gorge itself. This charge destroyed the gorge
casemates, and buried the commanding officer and 140 men under
the débris. The fall of this mass of stuff caused the hand-grenades
heaped up in the casemates to detonate and set off four mines, laid
under the foundations. The wounded and remnants of the garrison
were thus shut up in the casemate, with only one small exit into the
gorge ditch, through which they had to crawl. Not being able to get
into the interior of the work, the garrison could do nothing to hold
the position. The enemy perceived this at once, quickly got into the
interior of the work, and seized the gorge, where they brought
machine-guns. About 10 o'clock we saw a white flag on the
fortification. It is not known who raised it. General Stössel and the
Fortress Commandant were informed, and within a quarter of an
hour the following order was received from General Stössel:

'"In view of the difficulty of getting out of the Fortification, the


remainder of the garrison may surrender; those who can escape
may try to."

'This order was transmitted by telephone to the work, whence a list


of those alive and wounded was telephoned back. The telephone
was then cut to prevent the enemy hearing what we said. It was
thought that, having seized the fortification, they would try and
storm Tumulus Battery. General Gorbatovsky, therefore, ordered the
garrison of this battery to be reinforced by one company of infantry,
and a company of sailors to be sent into the trenches of the second
line from Laperoff's battery along Vladimir and Mitrofanieff Batteries.
About eleven o'clock the enemy's fire ceased. Gorbatovsky decided
to hold the second line, having Tumulus Battery on the left flank and
Eagle's Nest on the right. He told the Commandant of this, and
asked leave to carry it out at night....'
From Stössel's order and subsequent dispositions on that day it is
clear that he had no idea of the relationship between the second and
third lines. Among other things he ordered the left flank of the
second line to be held, while part of the third line was held
(Stonebroken Ridge and Big Hill). From this it was plain that Stössel
had never seen the second line of positions, and had never been on
the hills near.
After the fall of Erh-lung-shan Fort the besiegers opened a heavy fire
on the north-east front from Tumulus Battery to Eagle's Nest. At 1
p.m. on January 1 they delivered an attack from the fort on Rocky
Ridge. Our troops having lost heart, and being badly demoralized,
gave way; but our gun-fire checked the enemy's assault, and the
position remained in our possession. However, despite the very strict
and definite orders given by the Commandant that the Chinese Wall
from Rocky Ridge was to be held at all costs (it was quite possible),
as soon as dusk came on, the abandonment of this wall and Rocky
Ridge began under Fock's orders. The retirement was executed
without any interference from the enemy, and we were able to take
with us all except the heavier guns. At five o'clock on January 1 our
troops were distributed along the second line—Tumulus Battery,
Vladimir Battery, Mitrofanieff Hills, Eagle's Nest, the portion of the
Chinese Wall behind Chi-kuan-shan Fort, and Kuropatkin Lunette.
The enemy having now arrived at such a position, it seems a fitting
moment to mention in what directions the organization of Port
Arthur as a fortress had most failed.
By this time most of the many grave defects in the original
conception and subsequent execution of the material defences of
this stronghold had become only too painfully clear, though it had
not needed the test of bitter experience to make the more glaring
errors obvious. There were terrible faults in the original tactical
arrangement of the defences and in the details of the works
themselves.
The main line of permanent forts, the girdle, was much too close to
the objects to be protected—i.e., the dockyard and town. The
positions fortified by us were so close that, before capturing these
positions, the enemy were able to bombard the place, damage our
fleet, and demoralize the population. Some points of vital importance
were entirely unprovided with permanent works—i.e., 203 Metre Hill,
Angle and Long Hills—and were left for an improvised fortification,
which was carried out in a scrambling way after the place had been
completely invested. So little had these three positions been
considered important that until after May 18 no paths to them had
ever been made. Accepting the main line originally chosen, such as
it was, there were further defects in the forts themselves. They were
in many cases badly sited. On the eastern front the enemy had
commanding positions within two miles (Ta-ku-shan, Sia-gu-shan),
from which the interior of our defence could be seen and fired into,
and our communications shelled. This seriously hampered the
movement of troops and the transport of munitions. They were also
badly designed for their sites, having no good field of fire and much
dead ground in front of them. It is not enough to say they were ill-
concealed—they were ingenuously conspicuous. As regards
armament, our long-range heavy guns, designed to fight the
enemy's siege artillery, were placed right in the front, by which all
the advantages to be obtained by their ranging power was thrown
away. They naturally drew a concentration of the enemy's fire, and
were soon rendered useless. They were a positive curse to the
works in which they were placed, for they attracted a fire on to
these works, to which they could not efficiently reply. In design
many of the forts failed. They were not defiladed; they had no
covered communications and no proper shelters. The parapets were
feebly revetted with stones and sand-bags, and not having sufficient
traverses, could be swept by enfilade fire. The concrete was not
covered with earth, but was fully exposed. Lastly, such as they were,
our forts were not finished and ready by the time they were wanted.
The faults in the choice of position and ground were largely due to
the fact that the scheme was originally a paper scheme, worked out
on the map instead of on the ground. When the local engineers saw
things on the ground, it was too late for any alteration—the scheme
had been approved and confirmed. The paucity of works, their half-
finished condition, and the absolute lack of many essentials,
however, were all due to a cheese-paring, misplaced economy.
Money was scarce for the vital defences of Arthur, while millions
were being poured out on the palaces and wharves of Dalny, on a
well-equipped harbour, which was eventually to help the Japanese.
Let us now turn to the medical organization of the Fortress. Did that
correspond to the needs of the besieged Fortress? What influence
had that on its fate?
At the beginning of the war, in spite of the growth of the garrison,
there were the following hospitals: (1) A mixed hospital of 400 beds;
(2) the Reserve Hospital No. 1, 200 beds; (3) the Port Hospital, 40
beds; (4) two small civil hospitals. Of course, this quantity of
hammocks could not possibly suffice to meet the needs of a garrison
50,000 strong. If to the garrison be added the fleet, the civilian and
native population, the number of beds appears yet more absurd.
According to the field service regulations, the proportion of beds to
strength of troops should be 1 to 8; the proportion existing at the
commencement of the war was 1 to 100! In March was opened the
Naval Hospital, 200 beds, increased in July to 500; in April Reserve
Hospital No. 6, 210 beds; in May three reserve hospitals, 630 beds;
in June three reserve hospitals and a mobile hospital, 630 beds.
After the fortnight's assaults in August, when all the hospitals were
filled with wounded and were threatened with dysentery, Reserve
Hospital No. 11 was opened, with 1,200 beds, in the naval barracks.
Although, when once the war had started, it was daily to be
expected that the enemy might land and Port Arthur be thus
completely cut off, from the moment the first shot was fired the
equipping of the hospitals with medical and other appliances was
carried out at snail's pace. During the three months when the
Fortress was in direct communication with the capital, no single
additional bed was added—that is, omitting the Naval Hospital and
the Mongolia, opened within two months of the beginning of the war
for a special purpose. The former was arranged for during peace-
time and the building had already been finished. It was only with the
arrival of the new Commandant and the Sanitary Inspector of the
Fortress, Civil Councillor Subotin, that the organization of the
medical service was gradually placed on some sort of footing. Their
efforts were not particularly fruitful, because, instead of immediately
giving effect to the urgent representations and applications of the
Commandant, the authorities in the north spilt seas of ink, and
continued thus to spend their time till we were cut off. At the
beginning of the strict investment (after the fights on the advanced
positions) there were only 2,500 beds in the hospitals under the
Military and Naval Departments, and in the three hospital buildings
taken over by the Red Cross there were only 500 beds, or a total of
3,000—one-third of the proper number. During the period of the
strict blockade the number of beds increased. According to official
statistics, another 1,500 were added; but this addition can only be
taken as nominal, as there were practically no reserves in the
medical store depôts at the beginning of the war, and it was
impossible to procure any locally. But still, accepting these official
figures, during the worst period in Arthur 4,500 sick and wounded
could be tended. The minimum figure of sick at the end of the siege,
which cannot be disputed, was 15,000; the actual number was more
like 18,000. To show how these 'extra' 10,000 to 12,000 suffering
soldiers found shelter or relief means the unveiling of the most
revolting picture of the siege. About half of these 'extra' cases were
distributed somewhere in the hospitals above mentioned, and the
remainder were put in hastily-run-up sheds—little cemeteries of
living beings. In these during the last month of the siege there were
sometimes as many as a thousand sick men crowded together,
under the charge of one medical man, often a surgeon, who could
only be a helpless spectator of their sufferings.
Just glance at one of these 'infernos' in the month of December.
Outside it is freezing; inside, in spite of the musty and sickening
stench, the cold is intense. On all sides is filth, nothing but filth, and
on it and amongst it crawl millions of greasy grey lice. The silence is
only broken by the sighs and groans of the sick and the hungry—for
all in here are both sick and hungry. Death, the Liberator, is also
here. He is in every corner, at the doors, at the windows, crawling
along the floors and on to the bed-boards; he envelops everything—
and waits. At the front a man dies suddenly, and all is over. In the
hospitals Death is fought. But here, here, everything is in his power
—he only has to wait. Second after second, minute after minute,
hour after hour, men pass into eternity, into oblivion. There are
hundreds of cases of scurvy. They lie side by side on the floor, on
the bed-boards, underneath them, just as they were placed when
they came in—some in great-coats, some in tunics, some in
miserable boots, some barefooted. The faces are shapeless, swollen,
and distorted, and upon the yellow skin are large dark blue bruises.
The swollen gums, covered with hideous sores, project out of many
grinning mouths, and show the lack of teeth, which are continuously
falling out.... Here, far away from their friends and relations,
forgotten by all, in horrible, complete consciousness, they are
silently waiting the end.
And to think that much of this suffering might have been spared
these men had the Medical Service been properly organized, had the
highest authorities done their duty, instead of busying themselves
with writing orders. Things would not have been so bad even if
Stössel had confirmed the resolution of the Council of War about the
killing of horses on December 8. Feeding the garrison on horses'
flesh and white bread would at once have checked the growth of
disease; and there were more than 3,000 horses and 3,000,000
pounds of flour in the Fortress.
The hospitals which existed in peace-time and the hospitals which
expanded before the strict blockade answered their purpose fairly
well. Those which were opened after the commencement of the
strict blockade were far from doing so. They had no linen, nor beds,
nor medical supplies, to say nothing of a sufficient quantity of
trained nurses or doctors. The most disgraceful in this respect were
Reserve Field Hospital No. 2, of 1,200 beds, opened for infectious
cases and Mobile Field Hospital No. 5 (4th Division, General Fock),
situated on Tiger's Peninsula. What could be expected from hospitals
opened after the August assaults, when there was nothing left in the
place with which to equip them? For the 1,200 beds of No. 2 only
four doctors were told off. This hospital was renowned throughout
the Fortress for its horrors: there is no need to describe them. A
commission was appointed, which found the internal organization
and arrangements of the hospital so revolting that the Hospital
Inspector was immediately removed, and in his place was appointed
M. Menshoff, who had recently been Chief of the Police in Dalny. Of
3,500 patients received into it, 1,500 died. Mobile Hospital No. 5 was
little better.
The system of opening a hospital extension on the day of a big
attack was hopeless. It led to the sudden concentration of the sick
and wounded in the hospitals nearest to where the attack was taking
place, and where there was most congestion and appalling
confusion. The wounded sometimes received no medical assistance
for days together, as the personnel, working as it did for twenty-four
hours in the twenty-four, could not cope with such a big influx, and
they were carried from one hospital to another, often dying on the
road. Meanwhile, the other hospitals, situated some way off from the
locality attacked, did not take their share, owing to this inefficient
organization.
Many of the doctors made desperate efforts, but when dealing with
masses like this individual efforts were drops in the ocean.
Subotin was the Fortress Sanitary Inspector, immediately
subordinate to the Commandant, and he did his best; but there was
no independent central organization in the Medical Service of the
Fortress, which could have looked ahead and taken steps to
distribute the sick properly in the hospitals during attacks. The
Medical Service was dependent on the combatant authorities, whose
hands were much taken up with fighting. What was required was a
central administration, which could have foreseen what might
happen and have controlled the arrangements. The officer in charge
should have been invested with high rank and great authority, and
should have had a properly trained personnel. Scurvy first made its
appearance in the Fortress at a very early date: as early as April it
appeared among the crew of the Pallada, but, thanks to timely and
energetic measures, it was then stamped out. Unfortunately, no
material preventive measures were taken against its recurrence, with
the exception of vague suggestions as to better food and to add
green food to the rations, though where better food could be got or
vegetables could be bought was difficult to say. The scurvy cases
increased from hundreds in October and thousands in November to
10,000 in December. The hospitals were so full of it that men were
afraid of going into them, and at the end of the siege preferred to
remain on duty, even when sick.
Of 18,000 sick and wounded reported on the day the garrison
marched out, 6,000 only were wounded; the balance were cases of
scurvy. There were really more, as many men only slightly ill were
doing duty. Dr. Kefel, of the Naval Hospital, on making an inspection
of the men on one section of the right flank on December 11, found
that 21 per cent. of these on duty had scurvy. Exactly a fortnight
afterwards, on his inspecting the same section, he found 40½ per
cent. suffering from it. These were the same men, for they had not
been relieved.
It was pointed out in his report on this that: 'If the spreading of
scurvy increases in the above arithmetical progression, then in every
fortnight we shall have 200 more on the sick list out of every
thousand in the fighting line, and in one and a half months there will
be no men left fit for duty....
'If extreme measures are immediately taken, and we make use of all
the meat, white bread, and antiscorbutic diet available, we may
hope that those who are now well may not catch it, that the slight
cases will not become worse, and that the worse cases will do
tolerably well. Therefore there are before us two alternatives: to
keep our food-supply and have, after a month and a half, not a
single serviceable soldier, or to have eaten up our supplies of
provisions at the end of six weeks, but during all that time to have
kept the garrison in fighting strength. The strategist, not the
arithmetician, can decide which is the more advantageous choice to
make for the Fortress.'
When this report was laid before General Stössel, with a proposal to
increase the ration, he replied: 'There cannot be so many men as
this ill in that section. It is nonsense; there are not half that number
there.' And so the question remained undecided. It was only at the
very end that an order was given for a slight increase.
To the question, 'Was it possible to have avoided this epidemic of
scurvy, and could we have checked it with what we had in Port
Arthur?' the answer is undoubtedly 'Yes!'
How exactly this could have been done is a harder question to
answer. From the moment we were cut off from the north the
rations of the garrison were gradually cut short, and by November,
when the men were physically and morally weakened, the rations
were reduced to the minimum. Instead of bread, biscuits were
issued, which could not really be counted as rations for scurvy cases,
as to these they were as useful as stones.
The progress of the disease might have been checked if (1) a
probable period of resistance had been thought out and fixed; (2) if
rational use had been made of all sources of supply—horses, mules,
cats, dogs, and flour. In the beginning of December more than
2,000,000 pounds of excellent flour was received. Had 3 pounds of
white flour been issued per man, it would have lasted for three
months. Half a pound of horse-flesh per man would have lasted for
six weeks, though the number of horses for transport purposes
would, of course, have been limited.
The first was not done, thanks to the chaos resulting from the
harmful interference of Stössel and Fock.
The second was decided on at the council of December 8 (at which,
by some incomprehensible oversight, the Sanitary Inspector of the
Fortress was not asked to attend), but was not confirmed by Stössel.

CHAPTER XLII
THE LAST DAY BUT ONE
The dawn of January 1, 1905, ushered in an anxious day. All the
roads near the forts were now so much under rifle and machine-gun
fire that movement on them soon ceased. In the Staff Office of the
section it was expected that the enemy would at any moment
commence to pound and then storm Eagle's Nest, which was now
the key to the position. Sure enough, about nine o'clock the
bombardment commenced, shell after shell with clockwork regularity
striking the top of the hill. The staff of the section went from their
usual observation-place to the dressing station, from which an
excellent view of the rearward slope of Eagle's Nest could be seen,
and which had a telephone. At noon Captain Galitsinsky, who was in
command of the work, began sending in alarming messages to the
effect that the enemy, by repeated rushes, were successfully
concentrating in force in front of the position, evidently with a view
to an assault, and asked that he might be reinforced. The assault
soon began, but made at first little progress in face of the garrison's
steady fire. General Gorbatovsky, commanding the section, kept the
Commandant regularly informed of the progress, and urged that our
guns should increase their fire. Our fortress guns poured in a fairly
heavy fire, but not so heavy as the circumstances warranted, as we
had but few howitzers, which alone could have been effective.
Galitsinsky continued anxiously to report the critical condition of the
position. Gorbatovsky never left the telephone, talking all the time
with either Fock, Biely, or the Commandant: he kept on begging for
reserves to be sent up, saying that without reinforcements he could
not guarantee the issue. Suddenly some infantry were seen running
back from Tumulus Hill, and it was ascertained that the enemy,
having climbed a spur in front of Eagle's Nest, had enfiladed some of
our trenches. The men in them wavered and then ran. The presence
of mind of Captain Stepanoff alone restored order and averted a
panic. A party of fifty sailors were sent up to Galitsinsky, followed by
a second party somewhat later, and the fight waged hotly, our men
with difficulty holding their own.
At midday, while the issue of the fight was in the balance, Rear-
Admiral Loschinsky received the following letter, No. 2,544 of
January 1:

'The state of the Fortress is becoming so critical that its further


resistance cannot be guaranteed. If it becomes necessary to
surrender, it is essential that the most important papers and
standards be sent away. I am, therefore, directed by General
Stössel to ask you whether it will be possible to send a
destroyer at any moment to Chifu on board which an officer
could be despatched with such papers. If this can be arranged,
the destroyer ought to keep under steam ready to depart, as it
will be impossible to foresee the precise moment when she will
be required. I have the honour to inquire if this can be done?
'Reuss.'
Loschinsky replied to the effect that a destroyer would be kept
always ready, and, to ship articles more conveniently, would lie
under Electric Cliff. The Statny, under Lieutenant Baron Kasinsky,
was told off for this. While this took place the Commandant was
occupied issuing orders for the defence of the north-eastern front,
and it never entered his head that anyone was then thinking out
arrangements in case of a surrender. He was not told of the letter
sent to Loschinsky, although the latter, in his capacity of Commander
of the coast defences, was immediately under him.
Meanwhile the assault on Eagle's Nest continued, and about 2.30
p.m. the telephone from it ceased to work. Everyone at the dressing
station was busy with his glasses watching the top of the hill, which
was shrouded in clouds of bursting shrapnel, when, to our intense
surprise, Galitsinsky, the commander of the place, suddenly arrived.
'How? What's happened? Why?'
'I was the last to leave. None of our men are there now.'
He looked exhausted, dishevelled, overcome.
The staff were much perturbed, for the loss of this important tactical
point decided the fate of the north-east front. Any minute the
Japanese might force their way along the valley and commence a
massacre. Our guns concentrated their fire on the position that a
few hours before had been ours; but soon Lieutenant Malchenko
could be discerned riding along the road past our position with a
large white flag!
When he was seen, someone laughingly said:
'Looks as if he were taking our New Year greetings to Nogi.'
But he was not armed with empty greetings. Alas! he was taking to
Japan an unexpected New Year's gift. He was the bearer of the
following letter from General Stössel to General Baron Nogi, dated
December, 1904 (no day of the month):
'Being acquainted with the general state of affairs in the theatre
of war, I am of opinion that no object is to be gained by further
opposition in Port Arthur, and so, to avoid useless loss of life, I
am anxious to enter into negotiations for a capitulation. If your
Excellency agrees, I would ask you to be so good as to appoint
accredited persons to negotiate concerning the terms and
arrangements for surrender, and to appoint a spot where they
may meet my representatives.'

The despatch of the parlementaire had been decided on directly


General Fock had brought word of the capture of Eagle's Nest, and
Colonel Reuss had been immediately summoned to translate the
above letter into English. No meeting of the Council of War was held.
There was no attempt made to persuade Stössel to alter his decision
to surrender. The Commandant was not even informed of the
intention to despatch a parlementaire.
The decision to give up the Fortress had really matured on the day
of the last meeting of the Council of Defence, for General Stössel
had that day despatched a telegram to the Tsar, in which he
reported that the men had become worn out, and that the Fortress
could not possibly hold out more than a few days.[42]
In this he was undoubtedly influenced by the desire to save the lives
of his close friends. If any of them had opposed the despatch of the
parlementaire, and had informed the Commandant of it, Stössel
alone would never have dared to do it. But he was supported, and
so risked ignoring Smirnoff and proposing the surrender.
Simultaneously with the despatch of the parlementaire, Rear-Admiral
Wiren, commanding the battleship and cruiser division, received the
following letter from Colonel Reuss:

'A letter has just been sent by a parlementaire from General


Stössel to General Baron Nogi proposing to begin negotiations
for a capitulation; there is, therefore, only to-night for you to do
what you consider necessary to your ships!'
Admiral Wiren, distinguished and gallant officer that he was, was
thunderstruck at such tidings, and immediately went off to Admiral
Grigorovitch, to whom it was also news. Thence he went to General
Biely, and even to the Commandant, who were both equally
thunderstruck at what he told them. From them he went to Stössel,
where the information of what had been done was confirmed.
The troops, who very soon heard of it, no longer remained troops. It
was absurd to count on their obedience. And is it to be wondered
at? They had fought long, obstinately, doggedly, dying and suffering
awful agonies. They had been accustomed to expect death, and now
—now—what did they not hear? Their hopes rose. They longed for
life. They did not wish to die, and no power on earth would have
again made them exchange these hopes for death. After the news of
the despatch of the parlementaire, it would have been impossible to
inspire 30,000 worn-out men, whose minds had already been
poisoned by the fatal doctrine of some of their leaders, with the idea
that the Fortress should be held to the last, and the senior
commanders recognized this. When the Commandant went to the
Admirals, and a council was held, with him in the chair, to consider
what had best be done to avert a shameful surrender, they all came
to the inevitable conclusion that there was not the slightest hope of
counting on the obedience of the troops already demoralized and
knowing all about the negotiations. The arrest of Stössel, Fock,
Reuss and others would have caused dissension in the garrison,
perhaps a mutiny, and the last state of the Fortress would have been
worse than the first. The Commandant and Admirals accordingly
wisely refrained from taking any active steps, in order to avoid the
awful scandal, which would only have increased the shame
surrounding the surrender, and would have availed nothing.
Admiral Wiren issued orders for the ships under his command to be
disabled by charges being exploded in their most vital parts
(engines, boilers, etc.), but though every precaution was taken, the
last demolitions were only brought off by the morning of January 2.
The Sevastopol on that morning was tugged out by the Silacha to a
depth of 30 fathoms, and her Kingston valves[43] were opened, with
the result that she heeled over to starboard and quietly foundered.
It was impossible to blow up the large number of guns in the
Fortress as well as its munitions of war, as, according to the terms of
the capitulation, all the forts, guns, ammunition, etc., were to be
handed over intact. During the afternoon and night several guns
were destroyed and much ammunition was buried; but General Biely,
by Stössel's direct orders, strictly forbade this, as the enemy had
said they would make reprisals if the guns, etc., were found
destroyed. Some obeyed, others did not. Certainly most of the
Artillery spent the night destroying their weapons and equipment.
From the Raschevsky-Schwartz Diary, January 1, 1905.

'The firing gradually slackened, and about 6 p.m. ceased.


Deathly silence took the place of the constant noise of firing and
roars of explosions, even the whistling of bullets overhead
ceased. Tired and anxious, we went to the dressing station,
where we bolted some food, and then went to the New Chinese
town to the staff quarters of the section. We had scarcely lain
down to snatch a little rest, when a mounted scout arrived with
a letter from General Fock, in which he ordered Gorbatovsky
immediately to carry out his orders, and abandon the third
defensive section, for which he gave no reasons. He added that
the section up to Fortification No. 2 was also to be evacuated.
[On December 22, Fock, realizing the importance of this section,
had ordered me to draw up a scheme for strengthening its
defence. I had done this on the 23rd, and had carried the work
out in two days.] Nothing was left for us but to obey the orders,
and orders to this effect were accordingly issued by eight that
evening. And so the whole of the north-eastern front and almost
half of the eastern front was in the enemy's hands. The Fortress
could no longer hold out, as all roads to the town were in the
hands of the Japanese, and from Zaliterny Battery they could
demolish the town at leisure. It is inexplicable how anyone
understanding the great importance of this section and of B
Battery could have ordered their abandonment without a fight.
'At the same time a second message was received, in which it
was said that the Japanese had agreed to the negotiations, and
had ceased firing, requesting that we also should cease. The
horrible day gave place to a warm, quiet night, and the unusual
silence seemed uncanny. Suddenly explosion after explosion
rang out from the harbour—our battleships being blown up. It
was the last straw....'

The letter referred to above, in which General Gorbatovsky was


ordered immediately to carry out instructions with regard to the
abandonment of the third defensive position and the portion up to
Fortification No. 2, is now in his possession. The abandonment of
these positions was in no way warranted by circumstances, and to
carry out such a retreat without fighting was most demoralizing to
the troops. The negotiations for a capitulation were still before us,
and had we retained something 'up our sleeve,' we could have
bargained obstinately and have threatened to hold out longer, in
order to obtain better terms. This threat would not have been an
empty one.
At dark two huge conflagrations burst out from Eagle's Nest, lighting
up the whole north-east front. Port Arthur lay silent—more silent
than it had been for five long months—while the tongues of flame
seemed to lick the low clouds which brooded over the Fortress and
its triumphant foe. The silence was short-lived, however, for soon
several muffled explosions from the direction of the harbour and the
forts showed what Wiren was doing to his ships and the artillery to
their guns. Another fire broke out near the harbour, and the town lay
bathed in its blood-red glow. From the summit of Quail Hill the
picture of Port Arthur on its last night—last night as a portion of the
Russian Empire—was tragic enough. The place seemed to shudder
at each dull explosion, as if it knew that it was near its end. Its
former owners, having once more bought it at the cost of thousands
of lives, were standing on the threshold of their great holiday and of
the long-coveted prize.

FOOTNOTES:
[42] The text of this message has been quoted.—A.B.L.
[43] Valves which control the sea-water inlets of a ship.—E.D.S.

CHAPTER XLIII
THE END
Almost before dawn next morning, on the eastern front near Signal
Hill, was sounded the last note in the titanic struggle for Arthur.
Some volleys rang out on the quiet air, died away into independent
firing, then stopped. Boom! boom! went two guns, and then all was
silent. It appeared that the Japanese, thinking that Signal Hill was
only held by outposts, decided to seize it under cover of night. They
advanced without even taking the usual military precautions.
Unfortunately for them the hill was held by a company of infantry,
which, having noticed their approach, allowed them to get within
short range, and then poured volley after volley into them. Twenty
dead and eighty wounded were left on the ground. They wavered,
and our men charged with the bayonet. The fight continued for
some moments, costing us five wounded and one killed.
At daybreak all the hills on both sides swarmed with men who had
recently been foes: they stared at each other fascinated. The two
great masses of men differed but little from each other. Both had
come here to die, to die without a murmur and obediently. The only
difference was that on the one side they died for duty and for an
object understood by all, knowing their own superiority; on the other
they died for the same reason, but feeling their inferiority. The latter
it was who drank the bitter cup. Their one hope now was that they
should be spared the fate of being taken prisoners of war.
Negotiations were being carried on that day, and, of course, those
responsible would spare them the shame of imprisonment. But no!
They had to drain the dregs.

ADMIRAL WIREN.
A carriage was seen driving from the District Staff Office; it
proceeded quickly round the central Mandarin Road to the village of
Siu-shuing, the place appointed for the meeting. In it was Colonel
Reuss, who was escorted on horseback by Colonels Khvostoff,
Dmitrevsky, Captains Schesnovitch, Golovan, Student Lebedeff
(interpreter), and Malchenko. Before they started, General Stössel, in
the presence of Fock, told them all that he had given all instructions
and full authority for the conclusion of the capitulation confidentially
to Reuss, and that Reuss had also been given a letter for General
Baron Nogi. Stössel, Fock, and Reuss were nervous; they were also,
it seems, in a great hurry, for no lawyer was asked to look over the
terms of capitulation, nor was one present even when the terms
were signed.
The Commandant, holding aloof from any participation in the
surrender, sent the following cipher telegram to the Commander-in-
Chief, dated January 2, No. 1,300:

'General Stössel has entered into negotiations with the enemy


for surrendering the Fortress without informing me, and in spite
of my opinion and that of the majority of the commanding
officers.'

Reuss, with his companions, soon reached the appointed spot. They
were met by the Chief of the Staff of the Japanese Army, who
handed to them the proposed text of the agreement,[44] written in
English. He gave them an hour in which to think it over, and went
away. Reuss then read the contents aloud to the others. Golovan
began to protest; he was cut short. 'They are the victors; we must
submit to their demands.' After a short conference and passionate
protests from Khvostoff, Golovan, and Schesnovitch—as a matter of
fact their protests were waste of breath, for Reuss alone had plenary
powers, the others being only there for show—Reuss agreed to
make three alterations: (1) That the garrison should not be made
prisoners of war; (2) that officers should be permitted to take their
orderlies with them; (3) that the allowance of baggage should be
increased. The Japanese returned punctually within the hour, and
took away the text of the capitulation with the alterations for
consideration. After a quarter of an hour they returned, and said
definitely:
'We only agree to the second alteration. Will you sign?'
Reuss pondered for a moment, then said:
'I will.'
I will not bore the reader with the terms of the convention, which
are now well known, or the procedure of signing. No sooner was the
shameful document signed than Reuss sent a Japanese messenger
to Stössel with a note, saying:
'The capitulation is signed, and, in accordance with it, the
destruction of all property must be immediately stopped.
Stössel at once replied:
'I have done everything; tell the Japanese.'
The news of the surrender being an accomplished fact soon spread
among the garrison. Our men seemed suddenly to change their
natures, all discipline went to the winds, and rioting commenced.
Some, throwing their arms away, went straight down to the town,
which became one vast scene of drunkenness and orgy. The shops
and stores were looted, and wholesale robbery was the order of the
day. The crowd broke up everything they could, amongst other
things the library of the Novy Kry. The officers, seeing that it was
hopeless to try and cope with their men, hid from the maddened
crowds.
And now a few words as to General Stössel and how he took the
surrender. When the riot was reported to him, he at once became
alarmed, and asked for a hundred Japanese soldiers as a guard over
his house and property. Nogi sent the men, fully armed and
equipped. Fearing that matters would become serious, Stössel sent
the following note to Smirnoff:
'The strictest steps must be taken at once to deal with the looting
which has commenced. I would request you to be so kind as to send
out patrols. Reuss tells me that the terms of the surrender are
honourable. Please excuse pencil.'
It is difficult to understand what was in his mind when he wrote that
note. Was he laughing at the Commandant, or had he gone off his
head? As soon as Irman heard of the surrender he went to Smirnoff.
'Is it true, sir, that the Fortress has been surrendered?'
'I know nothing about it. Stössel has done everything without
reference to me. Go and ask him.'
Irman went at once to Stössel, and having ascertained that the
Fortress had been given up, he asked leave to go to Chifu on a
destroyer: he wished to break through to the army in the north. But
Stössel flatly refused permission, saying:
'Good heavens! what are you talking about? What are we to do with
all the gold vases? How am I to get them away? Why, the Japanese
might get them; we must save them.'
'If you want to make certain that the Japanese don't get them, sir, I
should throw them into the sea,' was Irman's answer.
Stössel was referring to the gold vases, goblets, spoons, etc., looted
from the Pekin Palace which were kept in Arthur. The gold plate had
been kept under special arrangements in the quarter-guard of the
12th Regiment, but when this corps left for Manchuria the plate was
left behind. On the evening of January 3 a mysterious cart arrived at
the quarter-guard, and disappeared in the dark of the night.
Some of the questions put to Stössel later at the Commission of
Inquiry, and his replies to them, may help to show how he was
occupied at this time. When asked by Major-General Roops why he,
contrary to all military regulations, took out of Arthur some thirty-
eight cartloads of his own property, he replied:
'I did it with the permission of the Emperor of Japan.'
On being asked why he did not share the fate of the garrison and go
into imprisonment, he answered:
'I was ordered not to by Her Imperial Highness the Tsarina.'
He had indeed received a telegram from the Empress in which she
had said she would be glad to 'see him in Russia.' The Emperor and
Russia did not at that time know what Stössel was!
When he was asked by the Commission why he surrendered Port
Arthur on his own responsibility, and did not summon the Council of
War to consider the question, he said:
'There was no time for that. I forestalled the Japanese, and did not
give them the possibility of breaking into Arthur; I was thus able to
prevent a street massacre.'
And this was the cry of all the whole Stössel clique before the
Committee of Inquiry.
One extract from the diary and I have finished:
'January 2, 1905.—On the way to the rendezvous of the Japanese
Commission appointed to take over, we met an officer of the
Japanese General Staff who greeted us in Russian. Ribnikoff at once
recognized him to be a man called Ito, who had been in Arthur for
several years as a watchmaker!'
Small wonder they beat us!
So it ended—so ended Russian Port Arthur. From its loss—from this
mighty struggle, this long-drawn-out nightmare of suffering, this
death of all our aspirations—new hope is born to our nation, a hope
of better days.
Salus patriæ. Suprema lex est.

FOOTNOTES:
[44] The text of this capitulation was drawn up two years before
by one of the most able Japanese lawyers.

CONCLUSION[45]
As this book leaves the hands of the printer, the columns of the daily
press are conveying to the world the terms of the indictment of the
chief characters mentioned in it for their share in the surrender of
the Fortress of Port Arthur to the Japanese. As this constitutes an
official confirmation of much that I have written, I include it in my
book, so that the reader may be in a position to judge if the title of
my work is justified.
This indictment, I may add, has been drawn up by three separate
Commissions, composed of the highest Government officials and
experts in military law.
Official Indictment.
Lieutenant-General Stössel, of the retired list, is charged as follows:
1. In that he, having on July 3, 1904, received an order from the
Commander-in-Chief of the Army in Manchuria to hand over
command of the Fortress of Port Arthur to its Commandant,
Lieutenant-General Smirnoff, and to leave the Fortress, disobeyed,
and, remaining in the Fortress, retained command of it—an action
provided for under Article 255, Book XXII., of the 'Military Code of
1869,' third edition.
2. In that he, in defiance of Order No. 339 of April 27, 1904, by the
Viceroy in the Far East, did interfere with the powers and duties of
the Commandant of the Fortress, thus undermining the latter's
authority, shaking public confidence in him, and so diminishing the
defensive capabilities of the Fortress. The following are instances of
such interference:

(a) Granting permission over the Commandant's head, and


against his orders, for supplies to be taken out of the Fortress.
(b) Appointing Civilian Counsellor Riabinin to the charge of the
Medical Department without making him subordinate to the
Commandant of the Fortress.
(c) Transferring the Dalny Hospital, in opposition to the
Commandant's orders and to the detriment of the public service,
to a site selected by himself.
(d) Removing the Chief of the Fire Brigade, Weykanen, from
duty.
(e) Sending the Gendarmerie to Liao-tieh-shan.
(f) Closing the printing-offices of the Novy Kry, and ordering the
arrest of M. Nojine, who was on the staff of that journal.
(g) Stopping work on the second and third lines of defence.

Provided for under, etc.


3. In that he did not in time take proper steps to increase the
quantity of supplies in the Fortress, as follows:

(a) By not supplementing the reserve of vegetables, although


this was quite possible.
(b) By not arranging to requisition horses, in accordance with
the Mobilization Regulations, and to increase the number of
cattle in the Fortress.
(c) By not sanctioning the Commandant's request that the
rations of horse-flesh might be increased, a course which was
absolutely necessary to maintain the strength of the worn-out
garrison.
Provided for under, etc.

4. In that he, during the siege, received and read certain


'Memoranda,' written by Lieutenant-General Fock, which were
composed in a derisive and offensive spirit, and of a nature
calculated to undermine the authority of, and bring odium upon,
several of the Commanders, subvert discipline, and lower the moral
of the garrison; and, in spite of their harmful influence upon the
defence, took no steps to prevent their publication and circulation
among the troops.
Provided for under, etc.
5. In that he, for his personal ends, sent reports to the Commander-
in-Chief of the Army in Manchuria on May 27 and 31, and to the
Viceroy on May 30, referring to the battle at Kinchou, in which he, in
contradiction to the actual facts and to the actions of himself and
those present, asserted that 'In this warm corner we fired every shell
we had got,' and that 'we retired in perfect order on Nangalin,' and
drew up these reports in such a manner as to make it appear that
he, General Stössel, had in person acted with great energy and
directed operations, while—

(a) During the battle at Kinchou, he—General Stössel—remained


in Port Arthur, and personally took no part in the action.
(b) There was a large quantity of ammunition at Nangalin
Station for the quick-firing guns, as was known to all the
artillery units.
(c) The retirement on Nangalin was carried out in great haste
and in complete disorder—so much so that certain units rushed
through and broke down the wire entanglement obstacle.
Provided for under, etc.

6. In that he, for his own advantage, and in order to place the
actions of his subordinates in the most favourable light, on May 28,
1904, reported to the Commander-in-Chief of the Army in Manchuria
that the force under Lieutenant-General Fock 'was falling back
gradually towards Wolfs Hills'—a statement directly opposed to facts,
as the retirement of the force direct on to Wolf's Hills (the last of the
advanced positions) was effected in complete disorder and in great
haste along a hilly road, blocked with transport and by the
inhabitants of Dalny retreating to Port Arthur.
Provided for under, etc.
7. In that he, for his own advantage, and in order to represent
himself as taking a part in various actions (which did not take place),
on June 14, 1904, reported in writing to the Commander-in-Chief of
the Manchurian Army as to his own great activity in the conduct of
the defence, in which report he stated, in opposition to facts: ' ... I
always make a point of being in every possible engagement ...';
while from February 8, 1904, to June 14—i.e., up to the date of his
letter to General Kuropatkin—not a single engagement with the
Japanese took place (except the battle at Kinchou, in which he—
General Stössel—took no part) but the bombardments, during which
the whole population of Port Arthur were in equal danger.
Provided for under, etc.
8. In that he, in the hope of justifying the prearranged surrender of
the Fortress to the enemy, on December 29, 1904, reported to the
Tsar in a telegram that: 'By the capture of Fort No. 3 the Japanese
have become masters of the whole north-east front, and the
Fortress can only hold out for a very few days. We have no artillery
ammunition ...'—a report which was not in accordance with the
facts, as at the Council of War held on that day (December 29),
when the members by a large majority declared themselves in
favour of holding out to the last moment, both Major-Generals Biely
and Nickitin declared that there was sufficient ammunition in hand
for a further defence.
Provided for under, etc.
9. In that he intentionally, improperly, and with false statements
recommended:

(a) Lieutenant-General Fock for promotion to the Third Class


Order of St. George for the battle which he lost at Kinchou, and
in which he displayed complete incompetence;
(b) Major-General Nadein for promotion to the Third Class Order
of St. George for the same battle, in which he in no way
distinguished himself;
(c) Major-General Reuss for the Fourth Class of the same Order,
this officer himself asserting that he had done nothing whatever
to merit such a reward.

Provided for under, etc.


10. In that he, while in command of the District, and being the
senior officer in a fortress which was being besieged by the
Japanese, and of which the Commandant was subordinate to him,
decided to surrender the Fortress to the enemy, and, in order to do
so, in spite of the opinion of the great majority of the Council of War
held on December 29, 1904, in favour of the continuation of the
defence (which was in every way possible), and without, in
accordance with the Regulations, convening a fresh Council of War,
did between 3 and 4 p.m. on January 1, 1905, despatch a
parlementaire to General Nogi, commanding the besieging army,
proposing to enter into negotiations for the surrender of the
Fortress, although all means of defence had not been exhausted, as
the fighting strength of the garrison and the amount of war material
and of supplies permitted of a continuation of it.
In that he, after this, agreed to the proposal of Lieutenant-General
Fock, commanding the land defences, to abandon Little Eagle's Nest,
Kuropatkin Lunette, and B Battery without a fight, which action
greatly diminished the power of resistance of the Fortress.
In that he, on the following day—January 2, 1905—authorized
Colonel Reuss, his Chief of the Staff, to conclude definitely the
capitulation without giving him any precise instructions as to the
terms to be insisted upon on our side, in consequence of which
Colonel Reuss signed, in the village of Siu-shuing, to terms which
were disadvantageous and derogatory to the dignity of Russia, in
which action General Stössel himself failed to perform his duty
according to his oath and to the honour of a soldier.
In that he, having surrendered the Fortress to the enemy, did not
share the fate of the garrison by accompanying it into military
confinement.
Provided for under, etc.
Major-General Reuss is charged as follows:
1. In that he, while Chief of the Staff of the Kwantun District, and
being aware of General Stössel's intention to surrender the Fortress
of Port Arthur to the Japanese at a time when the fighting strength
of the garrison and the quantity of munitions of war and of supplies
assured the possibility of a continuance of the defence, concurred in
this intention, and assisted General Stössel in the execution of it—for
instance:

(a) At the meeting of the Defence Committee on December 8,


1904, and at the Council of War on December 29, 1904,
exaggerating the critical state of affairs, and declaring that
further opposition was useless, and that the Fortress should be
surrendered.
(b) Prematurely composing and despatching at General Stössel's
direction on January 1, 1905, a letter to General Nogi,
commanding the Japanese besieging army, in which proposals
were made for negotiations for a capitulation.
(c) On the following day, January 2, 1905, without demanding
definite instructions from General Stössel regarding the
conditions to be insisted on for surrender, going to Siu-shuing
village—the place appointed for the negotiations—and raising no
objections to the demands put forward by the Japanese
representatives, signing that same day to the capitulation of the
Fortress upon terms disadvantageous to Russia and derogatory
to her dignity, and by such action co-operating with General
Stössel in the surrender of the Fortress to the enemy.

Provided for under, etc.


Lieutenant-General Fock is charged as follows:
1. In that he, having received categorical instructions on February 27
and May 19, 1904, to make an obstinate defence, even to a defence
with the bayonet, at the Kinchou position, not only with the 5th East
Siberian Rifle Regiment, but with the 13th and 14th Regiments,
which were close at hand, and disregarding these orders and the
fact that General Stössel had himself undertaken the defence of
Inchenzy Bay, which was in rear of the position—

(a) When the battle had begun on the morning of May 26,
1904, instead of taking command, did go away to Inchenzy Bay
to select a position there for the 15th Regiment, in case the
Japanese should land there, and did not arrive at the attacked
position till 2 p.m.
(b) Did only send one of the four regiments present at Kinchou
into action, and thus did cause its separate destruction.
(c) Did not only fail to make any use of his reserves during the
battle, but did stop two battalions which were going up into the
fighting line, under orders from General Nadein.
(d) Without having exhausted every means of defence, and
without having recourse to the bayonet, did telegraph to
General Stössel in Port Arthur, in order to induce him to order a
retirement, as to 'the critical position,' and the complete lack of
gun ammunition, there being at the time a large quantity of
ammunition at the station of Nangalin.
(e) Having, in consequence of this, received instructions from
General Stössel to retire at dusk, did commence the retirement
in daylight, thus causing many casualties, and ceding to the
Japanese the fortified position at Kinchou, without having made
use of all the means at his disposal for its protracted defence.

Provided for under, etc.


2. In that he, during the battle of August 21, 1904, having received
an order from his immediate Commanding Officer—the Commandant
of the Fortress—to send two battalions of the 14th East Siberian
Rifle Regiment to the advanced forts on the north-east front, did not
at once obey the order, but entered into an untimely argument with
the Commandant, and did not himself accompany the last unit of the
reserve under his command.
Provided for under, etc.
3. In that he, having no official position in the defence from August
22, 1904, to December 16, 1904, and going round the positions on
his own initiative, under the pretext of assisting the defence, but
really in a cowardly desire to prove himself superior in bravery,
knowledge and ability to the other commanders, did allow himself to
discuss affairs and to issue 'Memoranda,' in which he not only
offensively criticized the actions of those who were not under his
orders—accusing them of incompetence and cowardice—but also
spread abroad the idea that the defence of the forts and fortified
positions should not be carried to such a length as to cause many
casualties, and did act in such a manner that his views and
'Memoranda' became known to the garrison at large (including the
soldiers), by which he shook the belief of the troops in the necessity
for, and the possibility of, holding the defences to the very last.
Provided for under, etc.
4. In that he, having on December 16, 1904, taken over the duties
of Commander of the Land Defences of the Fortress of Port Arthur,
and finding it impossible to hold Fort No. 2 any longer, did report this
fact personally to the Officer Commanding the District, and did not
report it to the Commandant of the Fortress, to whom he was
directly subordinate, and having received General Stössel's
permission on December 18, 1904, did order that this fort should be
abandoned and blown up without informing the Commandant.
Provided for under, etc.
5. In that he, while Commander of the Land Defences of the
Fortress, and being aware of General Stössel's intention to surrender
the Fortress of Port Arthur to the Japanese before all means of
defence had been exhausted, as the fighting strength of the garrison
and the amount of supplies and munitions of war assured the
possibility of a continuance, concurred in this intention, and assisted
General Stössel in the execution of it. For instance:

On December 1, 1904,[46] reporting to General Stössel that it


was necessary to send a parlementaire at once to General Nogi
with proposals to capitulate, and then, after its despatch, upon
his own responsibility, and in spite of the orders of the
Commandant, ordering, under threats, General Gorbatovsky,
who was in command of the defences on the east front, to
abandon Little Eagle's Nest, Kuropatkin Lunette, and B Battery
without a fight, which works were accordingly in the evening
abandoned by our troops, he—Lieutenant-General Fock—
knowing full well that by these dispositions of his he had placed
the defence of the Fortress under most disadvantageous
conditions should the negotiations for surrender be for any
reason broken off, and had enabled the Japanese
representatives to demand from us most disadvantageous and
degrading terms of capitulation.

Provided for under, etc.


Lieutenant-General Smirnoff is charged as follows:
1. In that he, suspecting, after the surrender to the Japanese of Fort
No. 2, the existence of an understanding between Generals Stössel
and Fock to reduce the Fortress to such a state as to justify
capitulation, and in despite of the responsibility resting upon him
under the terms of Article 57 of the 'Regulations for the Guidance of
Commanders of Fortresses,' did not immediately deprive General
Fock of his command, did not take energetic action to prevent the
above-named officers carrying out their plan, and confined himself
to despatching a telegram to the Commander-in-Chief, in which he
requested that he might be either given full power as Commandant
or relieved from all responsibility as such for the future defence of
the Fortress.
Provided for under, etc.
2. In that he, having learned on January 1, 1905, of the despatch by
General Stössel of a letter to General Nogi containing proposals for
negotiations for surrender, in spite of Article 69, Book XXII., of the
'Military Code of 1869,' third edition, and Article 57 of the
'Regulations for the Guidance of Commanders of Fortresses,' did not
convene a meeting of the Committee of Defence, did not insist that
General Stössel should act in accordance with Article 62 of the above
'Regulations,' and did not carry out the resolution of the Council of
War of December 29, 1904, to continue a protracted defence of the
Fortress.
Provided for under, etc.

FOOTNOTES:
[45] Written by the author in October, 1907. This was the official
indictment then published, and contains the main charges upon
which the officers stood their trial.—E.D.S.
[46]? January 1, 1905.—E.D.S.

APPENDIX I
General Fock's Memorandum re the Surrender of Fort No. 2. [Chi-kuan-
shan.]

In order that General Fock's motives may not be misunderstood, the


Memorandum written by him, in which he essayed to clear himself of
the charge of wrongfully abandoning Fort No. 2, is reproduced. It
needs, however some elucidation, both for the sake of clearness and
accuracy. Those who are not well acquainted with Fock's
proceedings in Port Arthur, both as a General and as an individual,
and with all the circumstances of the defence, might possibly
misunderstand this document, as the authors possessed a great
power of persuasion, both with pen and speech, and even now has a
considerable number of adherents and advocates.
Memorandum.

'Fort No. 2 was abandoned on December 18, 1904, with General


Stössel's permission and by my order. Next day I had a
conversation on the subject with General Smirnoff, who said:
'"Why did you surrender the fort? I would have sent you as
many reinforcements as you wanted; I have some 30,000 in the
Fortress. By abandoning it you have undermined the root of my
principle—that no fort should pass into the enemy's hands
except after the death of all its defenders."'

In saying this General Smirnoff was quite in the right. Fock did not
reinforce the garrison either in time or sufficiently, although quite
able so to do. The whole essence of the defence at the end
consisted in the use of mobile reserves for the reinforcement of
threatened points. It was by his intelligent anticipation of Nogi's
tactics and his skillfull movement and employment of reserves that
Smirnoff was able so long to check the attack.

' ... Later, when giving evidence before General Roop's


Commission, I was asked:
'"Did you take any steps to prevent the example of Fort No. 2
being followed, and to ensure that the principle that a garrison
should resist to the last should not be forgotten?"
'I was amazed at such a question, and that a principle, of which
I had never before heard and which is not to be found in any
text-book on tactics or field-service manual, should be assumed
by the Commission to be an irrefutable axiom, to ignore which
was a crime.
'But I was still more astonished a short time ago when, in a
paper submitted by General Smirnoff to the War Minister and
circulated amongst officials and other educated men, I saw the
following:
'"The surrender of Fort No. 2 struck at the root of the principle
that a fort 'dies, but does not surrender'—a principle preached
and reiterated by myself and all those in command. By the
example of the surrender of this fort the garrisons of the others
were shaken in their belief that forts are 'holies of holies,' only
to be captured after the death of the whole garrison defending

You might also like