stasvlasov / reading-journal-analysis

Shortest crash introduction to R using example of Group Reading Journal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shortest crash introduction to R using example of Group Reading Journal

Link to Group Journal https://goo.gl/nc9eZ1

What is R?

  • Cutting-edge Statistical Software
  • Programming Language to operate it
  • Free, open-source, huge community
  • Main Toolbox for Data Scientists

Basic set up

  1. Install R (download from CRAN - http://www.r-project.org/)
  2. Install external GUI

Basic elements in R

Numeric100, 0, -4.335
Character”some letters”
LogicalTRUE, FALSE
FactorDifferent levels
Complex2 + 3i
MissingNA, NULL, NaN

Basic Types of R Objects

  • Vectors
  • Matrix
  • Array - Multidimensional Matrix
  • Dataframe - Set of Vectors of the same length (but can be of different types)
  • List - Set of different objects (can also include Lists)
  • Closure - functions (instructions of what to do)

Basic syntax of R

# This is a comment

# This is a number. Number is a basic type of element.
42

# This is a Boolean. It is also a basic type of element.
TRUE

# This is a string. And this is also a basic type of element.
"John Bechara coordinates our course very well"

# This function c() creates an object of type vector that contains 3 strings
c("Noah", "Koen", "Geert")

# Actually when you create a vector containing one element (a number)
42

# This is a function being called with two arguments
paste("a","b")

# This is a function with an optional named argument
paste("a","b",sep=",")

# This is assignment. This is how you create objects of different types.
x <- c("Sjoerd", "Pauline", "Céline", "Kiki", "Marloes", "Patricia", "Sharon", "Lisa")
y <- seq(1,16,by=2)  # the first 8 odd numbers

# This is how to extract parts of a vector
x[2]  # "Pauline"
x[c(1,2,4)]  # c("Sjoerd", "Pauline", "Kiki")
x[3:5]  # try yourself

# This is how to bind two vectors to form a matrix
m <- rbind(x, y)
m <- cbind(x, y)

# This is how to slice a matrix
m[1,]  # the first row
m[,1]  # the first column
m[2:3,1]  # the first element of the second and third row

About

Shortest crash introduction to R using example of Group Reading Journal

License:MIT License


Languages

Language:HTML 99.1%Language:R 0.9%