Professional Documents
Culture Documents
Overview
1. The Basics
2. R Data Structures
3. Data Input/Output
4. In-Built Functions
5. Data Visualization
What R does and does not
• data handling and storage: • is not a database, but
numeric, textual connects to DBMSs
• matrix algebra • has no graphical user
interfaces, but connects to
• hash tables and regular
Java, TclTk
expressions
• language interpreter can be
• high-level data analytic
very slow, but allows to
and statistical functions
call own C/C++ code
• classes (“OO”)
• no spreadsheet view of
• graphics data, but connects to
• programming language: Excel/MsOffice
loops, branching, • no professional /
subroutines commercial support
R and statistics
• Packaging: a crucial infrastructure to efficiently produce, load
and keep consistent software libraries from (many) different
sources / authors
• Statistics: most packages deal with statistics and data analysis
• State of the art: many statistical researchers provide their
methods as R packages
R as a Calculator
> 1550+2000
[1] 3550
or various calculations in the same row
> 2+3; 5*9; 6-6
[1] 5
1.0
[1] 45
[1] 0
0.5
sin(seq(0, 2 * pi, length = 100))
> log2(32)
[1] 5
0.0
> sqrt(2)
-0.5
[1] 1.414214
> seq(0, 5, length=6) -1.0
[1] 0 1 2 3 4 5
> plot(sin(seq(0, 2*pi, length=100))) 0 20 40
Index
60 80 100
Variables
> i = 81
> sqrt(i) numeric
[1] 9
> 1>2
[1] FALSE logical
Object orientation
Vector
Matrix
Array
Factor
Data Frame
List
Vectors
• vector: an ordered collection of data of the same type
> a = c(1,2,3)
> a*2
[1] 2 4 6
Example:
>a
localisation tumorsize progress
XX348 proximal 6.3 FALSE
XX234 distal 8.0 TRUE
XX987 proximal 10.0 FALSE
Factors