Advertisements

To create a vector [0,1,3]:

> c(0,1,3)

Append to it:

> c=append(c,4)

Assume we have some matrix “mat” then we can index an element with:

> mat[ROW,COL]

All indexing is 1-based.

To extract a row:

> mat[ROW,]

And a column:

> mat[,COL]

The variables ROW and COL are integers.

To extract part of a column:

> mat[ROW_BEGIN:ROW_END,COL]

Also see:

> help(“Extract”)

To loop from 1 to 10 inclusive:

> for ( i in 1:10 ){…}

Advertisements