rasterToPoints(stacked) #this also gives the cell values of the raster layer or layers

rasterToPoints(stacked) #this also gives the cell values of the raster layer or layers

cr<-round(cor(a.ran)[2,1],3) text(.2,-.4,bquote(rho == .(cr)),cex=2)

boxplot()

I have found that this plotting function orders boxes in alphabetical order, at times, so if I want a particular order that the R god is not giving me, then I find it easiest to rename my categories in an alphabetical order in which I want plotted and then us the *names* argument to relabel the x-axis.

There is a nice R package googleVis that integrates google motion charts and chart tools with R

A tutorial here

hist(x)

abline(v = mx, col = "blue", lwd = 2)

http://stackoverflow.com/questions/6557977/add-mean-value-to-histogram-in-r

1. First make a plot without the axis you want using `xaxt="n"`

:

`plot(yy,xx,xaxt="n",xlab="")`

2. Then add the axis without labels

`axis(side=1,at=xx,labels=FALSE)`

where:

`side = 1`

(this example is for adding labels to the x axis)

3. Finally add the text:

`text(xx,par("usr")[3] - ofst, srt = g, adj = 1,labels=labs,xpd = TRUE)`

where:

`par("usr")[3]`

gives you the y coordinate for your x axis

`ofst`

is the offset at which you want to plot the labels away from the x axis (note the minus sign).

`srt = g`

this gives the angle to plot the labels, I like (e.g., `g = 45`

)

`labs`

is a vector of your labels

`xpd=TRUE`

plotting clipped to the figure region, also try `xpd=NA`

Many times I need to make a figure for a paper with multiple panels. What I do is line up the panels such that I can remove axes labels when side-by-side.

Then I manipulate the white space using the par function. There is a nice figure here that describes the proper arguments With the code that produces it.

The image is reproduced below

It is nice to plot regression lines that are not infinite like what abline gives, a line that spans the range of the data.

fline <- function(object) {

# ``fline'' <--> fitted line.

r <- range(object$model[,2])

d <- data.frame(r)

names(d) <- attr(object$terms,"term.labels")

y <- predict(object,d)

lines(r,y)

}

From here: https://stat.ethz.ch/pipermail/r-help/2008-June/165288.html