2. Schedule
1.Introduction to R
2.Graphics library
3.texmacs notebook
4.iplots library
5.rgl
overview for MATLAB and
IDL convertites
standard plotting
Mathematica style notebook
with latex output
4. Starting R
In the terminal type:
$ R
R version 2.5.1 (2007-06-27)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
>
$ R --no-save < myfile.R
$ R CMD BATCH myfile.R
5. Running programs
Open myfile.R in your favorite editor and type:
print("Hello World from R!")
Load R source file and execute
source("myfile.R")
Define a function
hello <- function(x) paste("Hello","World","from",x)
hello("R")
8. Matrices
a = matrix(runif(9),c(3,3))
a= matrix(1, c(3,3))
b = a %*% a
b = a %x% a
b = a %o% a
d=diag(1:3)+1
d[2,]
d[,3]
square matrix 3x3
matrix product
kronecker product
outer product
diagonal matrix
2nd row
3rd column
12. Factors
factors are also called
categories or enunms
a=c("a","b","a","c","a")
a.f = factor(a)
levels(a.f)
str(a.f)
summary(a.f)
vector
define factor
get unique levels of a
structure of factor
histogram
13. Data Frames
data frames are "excel" data
sheets
a=data.frame(x=1:3,
y=c("a","b","c"),z=runif(3))
str, summary
read.table()
read.csv()
read.delim()
read.fwf()
definition like a list
information about data frame
read data from source
21. Overview
GNU TeXmacs is a free wysiwyw (what you see is what you want)
editing platform with special features for scientists.
TeXmacs runs on all major Unix platforms and Windows.
Documents can be saved in TeXmacs, Xml or Scheme format and
printed as Postscript or Pdf files. Converters exist for TeX/LaTeX
and Html/Mathml.
39. Simple Example: colored spheres
rgl.clear("all")
rgl.bg(sphere = T, back = "lines")
rgl.light()
rgl.bbox()
x=runif(1000)
y=runif(1000)
z=runif(1000)
col=rainbow(1000)
rad=runif(1000)/10
rgl.spheres(x,y,z,col=col,radius=rad)
clear space
set background
some light
bounding box
some coordinates
set colors
set radii
generate the spheres