cheat sheet

Usefull R code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#> Reoder factor levels

mutate(x = stats::reorder(., x, FUN = mean))

arrange(desc(z), y) %>% mutate(x = factor(x, levels = unique(x)))

#> Reorder columns

relocate()

#> Become one or two columns in a vector

dplyr::pull() # using select or select 2 cols

tibble::deframe()

#> Recode columns values

mutate(x = case_when( conditions! ))

#> Drop if all colum have NA's

select(where( ~!all(is.na(.))))

Server access

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#> From internet

ssh flaaw57@server231.ipsp.uni-hohenheim.de
cd /work/workspaces
# mkdir flavio
cd flavio

#> In the office

ssh flaaw57@server231
cd /work/workspaces/flavio

#> Install miniconda

# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# bash Miniconda3-latest-Linux-x86_64.sh

Git projects

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#> create ssh key <#

ssh-keygen -t rsa -C "flavio.lozanoisla@uni-hohenheim.de" 

# include name to the ssh file

cat ~/.ssh/id_rsa.pub

#> clone repository <#
git clone "repository"

#> update server repository <#
git add .
git commit -m "info"
git push 

#> update local repository <#
git pull

Git useful codes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#> Import changes from origen
git pull

#> Push changes to origen
git add .
git commit -m "message"
git push 

#> re-write local files from origen
git fetch --all
git reset --hard origin/master
git pull origin master

#> Undoing Multiple Commits
git reset --hard <commit>

#> Force push to origen
git push -f origin master

Rstudio theme

1
2
3
4
if (!require("rstudioapi"))
  install.packages("rstudioapi")
rstudioapi::addTheme("https://lozanoisla.com/killa.rstheme"
                     , apply = TRUE, force = TRUE)

Install apps using pwsh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#> Install chocolatey <#
open https://chocolatey.org/install

Set-ExecutionPolicy Bypass -Scope -y

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -y

#> Install all apps :) <#
choco install avastfreeantivirus -y
choco install google-backup-and-sync -y
choco install googlechrome -y
choco install k-litecodecpackfull -y
choco install foxitreader -y
choco install winrar -y
choco install vlc -y
choco install aimp -y
choco install sharex -y
choco install teamviewer -y
choco install zotero -y
choco install r -y
choco install rtools -y
choco install r.studio -y
choco install git -y

#> apps repository <#
open https://chocolatey.org/packages

Bash

1
find . -type f -exec touch {} +
1
2
3
4
git rm -r --cached .
git add --all .
git commit -a -m "Versioning untracked files"
git push origin master