[R] padding specific missing values with NA to allow cbind

Rob Forsyth rob.forsyth at newcastle.ac.uk
Mon Jun 10 23:41:42 CEST 2013


Dear list

Getting very frustrated with this simple-looking problem

> m1 <- lm(x~y, data=mydata)
> outliers <- abs(stdres(m1))>2
> plot(x~y, data=mydata)

I would like to plot a simple x,y scatter plot with labels giving custom information displayed for the outliers only, i.e. I would like to define a column mydata$labels for the mydata dataframe so that the command

> text(mydata$y, mydata$x, labels=mydata$labels)

will label those rows where outliers[i] = TRUE with text but is otherwise blank

The first problem I have is that due to some NAs in mydata, nrows(outliers) < nrows(mydata) and I'm getting in a tangle trying to pad the appropriate rows of outliers

Thanks

Rob



More information about the R-help mailing list