Cheat Sheet to Install and work with R on Ubuntu

Tips and tricks to Install and work with R on Ubuntu

Run these commands in terminal

#Update and Install R
sudo apt-get update
sudo apt-get install r-base r-base-dev
sudo apt-get upgrade

# Know R version
R --version

Extract Part of a FASTA Sequences with Position by python script HERE

Run these commands in R terminal

# Know R version
sessionInfo()

# Know version of specific packages
packageVersion("ggplot2")

# check installed packages
installed.packages()

# list all packages where an update is available
old.packages()

# update all available packages
update.packages()

# update, without prompts for permission/clarification
update.packages(ask = FALSE)

# update only a specific package use install.packages()
install.packages("ggplot2")


# install packages from bioconductor
source("https://bioconductor.org/biocLite.R")
biocLite("ComplexHeatmap")

# install multiple packages from bioconductor
source("https://bioconductor.org/biocLite.R")
biocLite("ComplexHeatmap", "ggplot2")


# install packages from github
library(devtools)
install_github("jokergoo/ComplexHeatmap")


# start library
library('ggplot2')

Get multiple strings from a file and replace them in another file with AWK

Get multiple strings from a file and replace them in another file

I have multiple strings (old strings) and their sustitution (new strings) in tab limited format in a file named as string. I want to replace them in another file named as Inputfile and save in Outfile. 

Script

awk '
NR==FNR {
    old[NR] = $1
    gsub(/&/,RS,$2)
    new[NR] = $2
    next
}
{
    for (i=1; i in old; i++) {
        gsub(old[i],new[i])
    }
    gsub(RS,"\\&")
    print
}
' string Inputfile >Outfile

Examples For Sed Linux Command In Text Manipulation and File Handling

How to compare multiple sets using UpsetR