python training first steps

Today I train on Python skills.

All code is in R except where commented prior as “# Python code”

library(reticulate) # to enable python code chunks in R Markdown


Matplotlib is a visualization package/library.

# Python code
# Import matplotlib
import matplotlib.pyplot as plt

Using example data

# Python code
# Create some data
year = [1950, 1970, 1990, 2010]
pop = [2.519, 3.692, 5.263, 6.972]
# Python code
# Line plot
plt.plot(year, pop)
plt.title('Population Projections')

# Python code
# Scatterplot
plt.scatter(year, pop)



I tried to import a data set as csv and use pandas as well. What I found was that it’s not possible to use R Markdown interactively with Python commands. I do want to get Python work published in this blog, to do so I will follow this approach;

  1. Learn Python in terminal and anaconda
  2. Figure out how to publish HTML jupyter notebooks
  3. Figure out how to deploy those notebooks into this website