using WooldridgeDatasets, Statistics, DataFrames, FreqTables, Plots
Working with Jupyter Notebook
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:
- basic Markdown commands to format your text in
Markdown
cells - how to import and run Julia code in
Code
cells
Import and Prepare Data
Let’s start by loading all packages:
In the next step, we import our data and define important variables:
= DataFrame(wooldridge("affairs"))
affairs = freqtable(affairs.kids)
counts = ["no", "yes"]
labels
print(counts)
[171, 430]
Analyse Data
View your Data
To get an overview you could use first(affairs, 5)
.
Calculate Descriptive Statistics
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:
= mean(affairs.age)
age_mean print(age_mean)
32.48752079866888
Produce Graphic Results
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)