all information are availbale on https://course.img.cas.cz/ download the R from: https://www.r-project.org/ download the R-Studio https://www.rstudio.com/
RStudio is the most popular IDE (Integrated Development Environment) for the R statistical programing language. It offers a lot of features for managing a whole range of R code, from simple scripts to complex projects.
In addition to the menu on top, the RStudio window generally consists of four panels:
The top-left part shows the current open files. In the example screnshot, one file is open: an R Markdown file called “intro-to-r.Rmd”, which also served as the basis for this tutorial. The top-left panel is not visible if no files are open, such as when opening the RStudio program for the first time. If multiple files are open, each of them has their own tab at the top of the panel.
The bottom-left panel can display the following features (marked by corresponding tabs in the panel):
The top-right panel displays various information about the R session:
Finally, the bottom-right panel contains multiple tabs as well:
To test the console, paste the following command after the “>” character, which signifies that R is expecting user input. The following command adds two numbers and the result is printed on the following line:
2 + 3
Note: any spaces between the operand and the operators will be ignored. Their only purpose is to make the command easier to read. That is, “2 + 3” and “2+3” will both work.
Typing an incomplete command, for example “2 +”, will cause R to print “+” on the next line and expect more user input, i.e. the second operand for the operation of addition. Pressing the Escape key cancels R from asking for the last operand. In general, whenever the R console does not display the “>” character at the beginning of the line, it means that it espects the user to finish entering a command.
R implements multiple arithmetic operations. In the order of precedence, i.e. the order in which airthmetic operations are evaluated, R implements the following:
These can be combined to create more complex expressions:
(2 + 3) * 4 ^ (5 - 3)
Comparison, math functions (log, sin) etc.
R provides a list of other mathematical operators and functions.
For example, to compare whether the value of a variable is smaller than the value of a second variable, the operator “<” can be used. The result of this operation will be of logical type (TRUE/FALSE or T/F). Similarly, the operator “>” is used to test whether a value is greater than another. R also provides the operators “==” (“is equal to”), “!=” (“is not equal to”), “<=” (“is smaller than or equal to”“) and”>=" (“is greater than or equal to”“).
variable1<-7
2 < 4
2 > 4
2 == 4
6 != variable1
variable1 <= 3
5 >= 5
R also implements logical operators: AND: “&”, OR: “|” and NOT: “!”, which work with logical variables:
TRUE & TRUE
TRUE & FALSE
2 < 4 | 2 > 4
2 == 4 | 3 > 5
! FALSE
! 2 > 4
! 3 < 7
The following trigonometric functions are available: sin(), cos(), tan(), asin(), acos(), atan() and hyperbolic versions (sinh(), cosh(), tanh()), as well as the exponential function exp() (which computes e to the power of the given argument) and logarithm functions log(), log10() and log2(). The default logarithm base for the log() function is the natural logarithm base e, equal to exp(1). The functions log10() and log2() compute the logarithm in base 10 and 2, respectively. Other logarithm bases can also be specified for the log() function, using the “base” argument:
log(81, base=3)
The text in the R console can be cleared using the following command:
cat("\f")
By default, R comes preinstalled with a series of “base” packages that provide the most common functions, such as those described in this document. Additional R functionality can be installed in the form of “packages”. These are installed using the “install.packages()” command, giving the name of the package in quotes as an argument between the parantheses. For example, to install a package called “readxl”, which contains functions for reading and writing Microsoft Excel packages:
install.packages("readxl")
After a package is installed, it needs to be loaded in order for R to get access to the functions contained within the package. This is done using the library() function:
library("readxl")
Packages has to be installed on computer and then loaded into R-studio. There are three main resources
install.packages
)biociLite.R
script to install Bioconductor packages. To install core packages, type the following in an R command window)install_github
)## try http:// if https:// URLs are not supported
source("https://bioconductor.org/biocLite.R")
biocLite()
install and load these packages GenomicFeatures (from Bioconductor), tidyverse (from CRAN), ggbiplot (from Git vqv)