Re: [R] using apply to loop [SEC=UNCLASSIFIED]

2007-12-20 Thread Crombie, Joe
Hi Louis, You could try this: # find the index of the maximum value in each row of _data_, # disregarding the last column classified <- apply(data[,-(nclass+1)],1,which.max) ## or, if the maximum may be repeated: classified <- apply(data[,-(nclass+1)], 1, FUN = function(x) which(x == max(x))) #

Re: [R] vector sprintf argument [SEC=UNCLASSIFIED]

2007-11-29 Thread Crombie, Joe
Hi Tom, Try this: > G <- "Number: %s" > sprintf(G, toString(A)) [1] "Number: 3, 4, 5" Cheers Joe Joe Crombie Biosecurity and Information Sciences Bureau of Rural Science Canberra Australia p: +61 2 6272 5906 e: [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mai

Re: [R] random walk w/ reflecting boundary: avoid control construct? [SEC=UNCLASSIFIED]

2007-10-24 Thread Crombie, Joe
Hi Johannes, I came up with the following (assuming that if step[i] is independent of step[i-1] then it is also independent of -step[i-1]): Cheers Joe > # your (unbounded) random walk > k <- cumsum(c(0,sample(c(-1,1), 1000, rep = T))) > > #shift it to positive, to allow following calculation

Re: [R] partitioning data [SEC=UNCLASSIFIED]

2007-10-15 Thread Crombie, Joe
Hi Stephen, Check the help for predict.glm(). The argument for passing new data is actually 'newdata', as in: > pred = predict(glm.model, newdata=form[150001:20,-1], > type="response") Cheers Joe -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of

Re: [R] Break [SEC=UNCLASSIFIED]

2007-10-07 Thread Crombie, Joe
Hi, You can exit out of the 'identify()' routine by either: right-click > 'stop' Or click on 'stop > stop locator' in the top-left of the plot window. The script should continue with line1, line2 etc. Cheers Joe Joe Crombie Information and Risk Sciences Bureau of Rural Science Canberr

Re: [R] Time series graphs, question about using zoo [SEC=UNCLASSIFIED]

2007-09-20 Thread Crombie, Joe
Hi Fang, An easy way of doing this is by: > matplot(one, pch = LETTERS[1:4], type = 'b') Cheers Joe Joe Crombie Information and Risk Sciences Bureau of Rural Science Canberra Australia p: +61 2 6272 5906 e: [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[

Re: [R] Identify and plotting symbols. [SEC=UNCLASSIFIED]

2007-09-19 Thread Crombie, Joe
Or maybe: > while(length(ind <- identify(x,y,n = 1, plot = F))) > points(x[ind], y[ind], pch = 19) (highlights each point as you select it, until you click _stop_) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Crombie, Joe Sent: Thu

Re: [R] Identify and plotting symbols. [SEC=UNCLASSIFIED]

2007-09-19 Thread Crombie, Joe
Rolf turner wrote: >I have been trying, unsuccessfully, to use identify() to (simply) >return a list of the indices of points clicked on and overplot (with >say a solid dot) each clicked-on point so that I can see where I've >been. I.e. I don't want to see the indices printed on the screen; I