Re: [R] if ... problem with compound instructions

2006-12-31 Thread Bill.Venables
Step 1: quadrant <- 1 + (X[, 1] < 0) + 2*(X[, 2] > 0) This is not the usual labelling of the quadrants as '3' and '4' are interchanged. If you want to be picky about it quadrant <- ifelse(quadrant > 2, 7 - quadrant, quadrant) Step 2: angle <- atan2(X[,2], X[,1]) %% (2*pi) # I think this is w

Re: [R] if ... problem with compound instructions

2006-12-31 Thread Duncan Murdoch
On 12/31/2006 9:35 PM, Richard Rowe wrote: > I am having problems with the 'if' syntax. > > I have an n x 4 matrix, X say. The first two columns hold x, y values and > I am attempting to fill the second two columns with the quadrant in which > the datapoint (x, y) is and with the heading angle.