Logical vectors¶
## Comparisons
x < 3:3
x
[1] 3 2 1 0 1 2 3
x == 0
[1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE
x < 3:3
y < c(1:3,0,1:3)
x == y
[1] FALSE FALSE FALSE TRUE TRUE TRUE TRUE
## Logical operators
a < c(TRUE,FALSE,TRUE,FALSE)
b < c(TRUE,TRUE,FALSE,FALSE)
a & b
[1] TRUE FALSE FALSE FALSE
a  b
[1] TRUE TRUE TRUE FALSE
!a
[1] FALSE TRUE FALSE TRUE
a & !b
[1] FALSE FALSE TRUE FALSE
!(a  b)
[1] FALSE FALSE FALSE TRUE
x < 3:3
x > 1 & x < 1
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
x > 1  x < 1
[1] TRUE TRUE FALSE FALSE FALSE TRUE TRUE
a < c(TRUE,FALSE,NA,TRUE,FALSE,NA,TRUE,FALSE,NA)
b < c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,NA,NA,NA)
a & b
[1] TRUE FALSE NA FALSE FALSE FALSE NA FALSE NA
a  b
[1] TRUE TRUE TRUE TRUE FALSE NA TRUE NA NA
Downloadable R script and interactive version
 R Script: logicalvectors.R
 Interactive version (shuts down after 60s):
 Interactive version (sign in required):
Explanation
The link with the “jupyterhub” icon directs you to an interactive Jupyter^{1} notebook, which runs inside a Docker container^{2}. 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 ORCID^{3} 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/whatisorcid/
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.