Monthly Archives: May 2007

Repeat elements of a vector

May 17, 2007
By

Two methods. The first produces a vector, the second a one column matrix.x=1:10# Method 1rep(x,each=3)# Method 2matrix(t(matrix(x,length(x),3)))

Read more »

Repeat elements of a vector

May 17, 2007
By

Two methods. The first produces a vector, the second a one column matrix.x=1:10# Method 1rep(x,each=3)# Method 2matrix(t(matrix(x,length(x),3)))

Read more »

Convert image to matrix in R

May 17, 2007
By

This is how to use the Pixmap library to read in an image as a matrix.> library(pixmap)# the next command may only work on Linux> system("convert foo.tiff foo.ppm")> img To get info on your new object: > str(img) Although included in the previous output, the size of the image can be extracted by:>img@size Then to extract the red channel...

Read more »

Convert image to matrix in R

May 17, 2007
By

This is how to use the Pixmap library to read in an image as a matrix.> library(pixmap)# the next command may only work on Linux> system("convert foo.tiff foo.ppm")> img To get info on your new object: > str(img)Although included in the previous output, the size of the image can be extracted by:>img@sizeThen to extract the red channel...

Read more »

Calculate turning angles and step lengths from location data

May 16, 2007
By

anglefun <- function(xx,yy,bearing=TRUE,as.deg=FALSE){ ## calculates the compass bearing of the line between two points ## xx and yy are the differences in x and y coordinates between two points ## Options: ## bearing = FALSE returns +/- pi inst...

Read more »

Calculate turning angles and step lengths from location data

May 16, 2007
By

anglefun <- function(xx,yy,bearing=TRUE,as.deg=FALSE){ ## calculates the compass bearing of the line between two points ## xx and yy are the differences in x and y coordinates between two points ## Options: ## bearing = FALSE returns +/- pi inst...

Read more »