The following example is based on Script Descr-Figures
from Chapter 1 and
demonstrates the use of Jupyter Notebooks to document your work step by step.
We will describe the two most important building blocks:
Markdown
cellsCode
cellsLet's start by loading all packages:
using WooldridgeDatasets, Statistics, DataFrames, FreqTables, Plots
In the next step, we import our data and define important variables:
affairs = DataFrame(wooldridge("affairs"))
counts = freqtable(affairs.kids)
labels = ["no", "yes"]
print(counts)
[171, 430]
To get an overview you could use first(affairs, 5)
.
Now we are interested in printing out the average age. We start with its definition and use LaTeX to enter the equation: $$ \bar{x} = \frac{1}{N} \sum_{i=1}^N x_{i} $$ The resulting Julia code gives:
age_mean = mean(affairs.age)
print(age_mean)
32.48752079866888
In Chapter 1, we saw how to produce a pie chart. Let's repeat it here:
pie(labels, counts)
You can also show Julia code without executing it. You can use inline code
, or for longer paragraphs
bar(labels, counts)