This aggregated cheatsheet of our tutorial package Data-projects-with-R-and-GitHub summarizes the individual notes from the provided tutorials and additional information from recommended sources.
git enables collaborative project development (UZH
tutorial)
pull the recent version before starting your daily
workcommit the changed files to your local copy along with a
useful comment
push all “committed” changed to the remote copy
(e.g. GitHub)
pull before
doing a push!git finds a newer remote version of a file changed by you
with changes at the same spotsgit does not know what is the correct change<<<<,
>>>>
<<<<, >>>>, .. partsbranch is a “copy” of your project with an independent tracking
of changes
pull request
aims at merging your changes back into the projectvector = all elements are same data typelist = most general, can contain anything, any size, …data.frame/tibble = list of vectors (of same lengths)
[] = reduces the current object to the selected part(s) (same
data container)[[]] = provides a single element (element-specific data
container)$ = shortcut for [[]] with namefor or while loops)
for( VARIABLE in DATA ) {...}DATA is one by one stored in
VARIABLE before running {...}for( d in list( x="haha", y=1:3)) { print(length(d)) }if/else statements)
if ( CONDITION ) {..T..} else {..F..}else {..B..} is optionalCONDITION must evaluate to a single TRUE|FALSE:
triggers execution of respective {..T|F..} block
if ( 1:4 == 2 ) {} not working since check
returns four logic values!if ( version$os == "mingw32" ) { print("MS Windows user?") }function definition and
usage)
myFunction <- function (ARGUMENTS) {...}ARGUMENTS are optional (first should be the data to work
on)myFunction( .. ) using appropriate values for
ARGUMENTSreturn() in {...} (default: last “printed”
value is returned)list() or
vector c()for loop
generalizationfunction generalizationseq_along() to generate the list of valid indices of a
vector or listnames() to access the vector of element names of an
objectINPUT and OUTPUT of your function, i.e. what
do you need and what do you want to createINPUT will be all function arguments, i.e. the needed variables of
your codeOUTPUTfunction(){} construct/body and add a
return() statement to provide your OUTPUT