
Dr. Domenico Giusti
Paläoanthropologie, Senckenberg Centre for Human Evolution and Palaeoenvironment
NA
(not available/missing), NAN
(not a number),is.na()
function (logical result)TRUE
represented in R as 1, FALSE
represented in R as 0 (good to know when counting)[]
place an 'index vector' in square brackets to subset a vectorx[is.na(x)]
, x[!is.na(x)]
x[!is.na(x) & x>0]
(AND operator)x[1:10]
(first 10 values of x), x[c(3,5,7)]
(3rd, 5th and 7th values of x)x[-c(2, 10)]
(all values except the 2nd and 10th)vect["bar"]
names()
functionidentical()
functionComplete swirl modules '7: Matrices and Data Frames' and '8: Logic' and submit your successful completion via email (domenico.giusti@uni-tuebingen.de)
swirl modules won't count towards your final grade but are highly recommended to follow. Those topics will be covered on the final exam.
git remote add origin git@github.com:dncgst/test10.git
git branch -M master
(NOTE: RStudio names the principal branch master
; GitHub recently renamed it main
)git push -u origin master
git push -u origin master
from the command linegit remote add origin git@github.com:dncgst/test10.git
git branch -M master
(NOTE: RStudio names the principal branch master
; GitHub recently renamed it main
)git push -u origin master
git push -u origin master
from the command linemain
also in RStudioinstall.packages('usethis')
library('usethis')
usethis::use_git_config(user.name = "dncgst", user.email = "dncgst@autistici.org")
usethis::edit_git_config()
The best way to connect RStudio and GitHub is using your username and a Personal Access Token (PAT). To generate a personal access token, use the
create_github_token()
function from usethis. This will take you to the appropriate page on the GitHub website, where you’ll give your token a name and copy it (don’t lose it because it will never appear again!). How to Use Git/GitHub with R
library('usethis')
usethis::create_github_token() # accept default settings and generate the token
# copy the generated token
install.packages('gitcreds')
library('gitcreds')
gitcreds_set()
# enter your copied token
library(usethis)
use_github()
function, which will create a GitHub repo and connect it to your current RStudio projectThis image was created by Scriberia for The Turing Way community and is used under a CC-BY licence
Three principles should be kept in mind when constructing a research compendium.
compendium/
├── data
| ├── raw_data.csv
│ ├── my_data.csv
├── figures
│ └── fig1.jpg
├── src/analysis
│ ├── my_script.R
| ├── fig1.R
├── text/doc
│ └── manuscript.Rmd
├── DESCRIPTION
├── LICENSE
└── README.md
It contains code, data, text, figures + the computing environment is described in the Dockerfile
, the dependencies of files and how to automatically generate the results are described in the Makefile
(e.g., benmarwick/1989-excavation-report-Madjedbebe).
compendium/
├── data
│ ├── my_data.csv
├── Dockerfile
├── figures
│ └── fig1.jpg
├── Makefile
├── src/analysis
| ├── fig1.R
├── text/doc
│ └── manuscript.Rmd
├── DESCRIPTION
├── LICENSE
└── README.md
A version control repository can be a research compendium; A Makefile makes it executable; A reproducible environment makes it reproducible.
A Docker container can be seen as a computer inside your computer. The cool thing about this virtual computer is that you can send it to your friends; And when they start this computer and run your code they will get exactly the same results as you did.
A research compendium can be used in several ways, including (but not limited to):