Donnerstag, 28. Januar 2010

R - Open Source Statistics

[Intro Article.. R pretty much rocks. www.r-project.org , needs better GUI. ]

Basic Matlab Function Equivalents:

Matlab RDescription
ones(n,m)*a mat.or.vec(n,m)*a initialize matrix with values
rand(m)runif(n,min,max)n float random numbers between min&max.
  sample(min:max,n)picks n elements of the data given as first argument (i.e. integers!)
reshape(a,[n,m..])matrix(a,nrow=n,ncol=m)reshape data structure into a matrix
for i=1:30
    op(i);
end
for (i in 1:30); {
    op(i);
}
for loop!
function [x y z] = uvw(a,b,c=3)
    op(a,b,c);
end
uvw<-function(a,b,c=3) {
    op(a,b,c);
}
function definition 
a = [];a <- matrix(nrows=0,ncols=3)how to init a matrix to be grown dynamically
a = [b;c;d];a <- rbind(b,c)concatenate matrix vertically
a = [b,c,d];a <- cbind(b,c,d)concatenate matrix horizontally
......

Keine Kommentare:

Kommentar veröffentlichen