DECIPHER logo

  • Alignment▸
  • Classification▸
  • Homology▸
  • Oligo Design▸
  • Phylogenetics▸
  • Tutorials▾
  • Examples Gallery
  • Documentation
  • R Lessons
  • Bioinformatics
  • Home
  • News
  • Downloads
  • Contact
  • Citations

R Lesson #1 - Introduction

R is an open source software environment for computing. It can be downloaded for free from r-project.org. There are a number of graphical user interfaces for R, or it can be accessed from the command line. R scripts, such as the one below, are typically stored in plain text files with a '.R' extension.

Hide output
# this is a comment
> print("Hello, World!")
[1] "Hello, World!"
> 
> x <- "Hello, World!" # `<-` is left assignment
> print(x)
[1] "Hello, World!"
> x # equivalent to print(x)
[1] "Hello, World!"
> 
> "Hello, World!" -> x # `->` is right assignment (rare)
> x
[1] "Hello, World!"
> 
> x = "Hello, World!" # `=` is always left assignment
> x
[1] "Hello, World!"
> "Hello, World!" = x # R allows this left assignment!
> 
> # R contains many functions, such as `length`
> length(x) # said "length 'of' x"
[1] 1
> 
> x[1] # same as above, since length 1
[1] "Hello, World!"
> x[2] # NA since it does not exist
[1] NA
> 
> X <- "Good bye, world!"
> x # R code is case sensitive
[1] "Hello, World!"
> X
[1] "Good bye, world!"


Next Lesson >