Approval of US presidents

The following line is not really necessary, it is used here only to indicate that presidents is a pre-installed data example.

data(presidents)

The data contains quarterly data about presidents’ popularity. The function tsp() contains the time series properties: the starting point, the end point and the frequency in which the popularity is measured within years.

tsp(presidents)
[1] 1945.00 1974.75    4.00

With the functions start(), end() and frequency() we can obtain the respective time series properties.

start(presidents)
[1] 1945    1
end(presidents)
[1] 1974    4
frequency(presidents)
[1] 4
presidents[1:12]
 [1] NA 87 82 75 63 50 43 32 35 60 54 55
window(presidents,
       start=1945,
       end=c(1947,4))
     Qtr1 Qtr2 Qtr3 Qtr4
1945 NA   87   82   75  
1946 63   50   43   32  
1947 35   60   54   55  
nixon <- window(presidents,
                start=1969,
                end=c(1974,2))
nixon
     Qtr1 Qtr2 Qtr3 Qtr4
1969 59   65   65   56  
1970 66   53   61   52  
1971 51   48   54   49  
1972 49   61   NA   NA  
1973 68   44   40   27  
1974 28   25            
plot(nixon)
plot without title
presidents-timeseries_img_0.png
time(nixon)
     Qtr1    Qtr2    Qtr3    Qtr4   
1969 1969.00 1969.25 1969.50 1969.75
1970 1970.00 1970.25 1970.50 1970.75
1971 1971.00 1971.25 1971.50 1971.75
1972 1972.00 1972.25 1972.50 1972.75
1973 1973.00 1973.25 1973.50 1973.75
1974 1974.00 1974.25                

Downloadable R script and interactive version

Explanation

The link with the “jupyterhub” icon directs you to an interactive Jupyter1 notebook, which runs inside a Docker container2. There are two variants of the interative notebook. One shuts down after 60 seconds and does not require a sign it. The other requires sign in using your ORCID3 credentials, yet shuts down only after 24 hours. (There is no guarantee that such a container persists that long, it may be shut down earlier for maintenance purposes.) After shutdown all data within the container will be reset, i.e. all files created by the user will be deleted.4

Above you see a rendered version of the Jupyter notebook.5

1

For more information about Jupyter see http://jupyter.org. The Jupyter notebooks make use of the RKernel package.

2

For more information about Docker see https://docs.docker.com/. The container images are run with docker spawner.

3

ORCID is a free service for the authentication of researchers. It also allows to showcase publications and contributions to the academic community such as peer review.. See https://info.orcid.org/what-is-orcid/ for more information.

4

The Jupyter notebooks come with NO WARRANTY whatsoever. They are provided for educational and illustrative purposes only. Do not use them for production work.

5

The notebook is rendered with the help of the nbsphinx extension.