Chapter 1 Getting Started
Everything starts somewhere, though many physicists disagree.
— Terry Pratchett
As with any research project, one of the first steps in our Zipf’s Law analysis involves collecting/downloading the research data and installing the required software. Before doing that, it’s worth taking a moment to think about how we are going to organise everything. We will soon have a number of books from Project Gutenberg in the form of a series of text files, plots we’ve produced showing the word frequency distribution in each book, as well as the code we’ve written to produce those plots and to document and release our software package. If we aren’t organized from the start, things could get messy later on.
1.1 Project Structure
Project organization is like a diet: everyone has one, it’s just a question of whether it’s healthy or not. In the case of a project, “healthy” means that people can find what they need and do what they want without becoming frustrated. This depends on how well organized the project is and how familiar people are with that style of organization.
As with good coding style (Appendix G), small pieces in predictable places with readable names are easier to find and use than large chunks that vary from project to project and have names like “stuff.” We can be messy while we are working and then tidy up later, but experience teaches that we will be more productive if we make tidiness a habit.
In building the Zipf’s Law project we’ll follow
a widely-used template
for organizing small and medium-sized data analysis projects (Noble 2009).
The project will live in a directory called
which will also be a Git repository stored on GitHub (Chapter 6).
The following is an abbreviated version of the project directory tree
as it appears towards the end of the book:
zipf/ ├── .gitignore ├── CITATION.md ├── CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── Makefile ├── bin │ ├── book_summary.sh │ ├── collate.py │ ├── countwords.py | └── ... ├── data │ ├── README.md │ ├── dracula.txt │ ├── frankenstein.txt │ └── ... ├── docs │ └── ... ├── results │ ├── collated.csv │ ├── dracula.csv │ ├── dracula.png | └── ... └── ...
The full, final directory tree is documented in Appendix F.
1.1.1 Standard information
Our project will contain a few standard files that should be present in every research software project, open source or otherwise:
LICENSEis the project’s license. We’ll add it in Section 8.4.
CONTRIBUTINGexplains how to contribute to the project. We’ll add it in Section 8.11.
CONDUCTis the project’s code of conduct. We’ll add it in Section 8.3.
CITATIONexplains how to cite the software. We’ll add it in Section 14.7.
Some projects also include a
AUTHORS file that
lists everyone who has contributed to the project,
while others include that information in the
README (we do this in Chapter 7)
or make it a section in
These files are often called boilerplate,
meaning they are copied without change from one use to the next.
1.1.2 Organizing project content
Runnable programs go in
bin/(an old Unix abbreviation for “binary,” meaning “not text”). This will include both shell scripts, e.g.
book_summary.shdeveloped in Chapter 4, and Python programs, e.g.
countwords.py, developed in Chapter 5.
Raw data goes in
data/and is never modified after being stored.
You’ll set up this directory, and its contents in Section 1.2.
Results are put in
results/. This includes cleaned-up data, figures, and everything else created using what’s in
data. In this project, we’ll describe exactly how
dataare used with
Makefilecreated in Chapter 9.
Finally, documentation and manuscripts go in
docs/. In this project
docswill contain automatically generated documentation for the Python package, created in Section 14.6.2.
This structure works well for many computational research projects and we encourage its use beyond just this book. We will add some more folders and files not directly addressed by Noble (2009) when we talk about provenance (Chapter 13), testing (Chapter 12), and packaging (Chapter 14).
1.2 Downloading the Data
The data files used in the book have been archived
at an online repository called Figshare (covered in Section 13.1.2).
They can be accessed at the following URL:
We can download a zip file containing the data files by clicking
“download all” at the URL above,
before unzipping the contents into a new
(also called a folder)
following the project structure described above.
Here’s how things look once we’re done:
zipf/ └── data ├── README.md ├── dracula.txt ├── frankenstein.txt ├── jane_eyre.txt ├── moby_dick.txt ├── sense_and_sensibility.txt ├── sherlock_holmes.txt └── time_machine.txt
1.3 Installing the Software
In order to conduct our Zipf’s Law analysis, we need to have the following software installed:
Comprehensive software installation instructions for Windows, Mac and Linux operating systems
(with video tutorials) are maintained by The Carpentries
as part of their workshop website template:
We can follow those instructions to install the Bash shell, Git, a text editor and Anaconda.
If Make isn’t installed on your computer (check by typing
make -v into the Bash shell),
then it can be installed as follows:
- Linux (Debian/Ubuntu): Install it from the Bash shell using
sudo apt-get install make.
- Mac: Install Xcode (via the App Store).
- Windows: Follow the installation instructions maintained by the Master of Data Science at the University of British Columbia.
conda in the shell on Windows
If you are using Windows and the
condacommand isn’t available at the Bash shell, you’ll need to open the Anaconda Prompt program (via the Windows start menu) and run the command
conda init bash(this only needs to be done once). After that, your shell will be configured to use conda going forward.
With our project structure decided, data downloaded and software installed, we are now ready to start exploring our data.
1.6 Key Points
- Make tidiness a habit, rather than cleaning up your project files later.
- Include a few standard files in all your projects, such as README, LICENSE, CONTRIBUTING, CONDUCT and CITATION.
- Put runnable in a
- Put raw/original data in a
data/directory and never modify it.
- Put results in a
results/directory. This includes cleaned-up data and figures (i.e. everything created using what’s in
- Put documentation and manuscripts in a
- Refer to The Carpentries software installation guide if you’re having trouble.