[R] Multiple statements in tryCatch

2009-02-03 Thread Neil Beddoe
Hi, tryCatch seems to be evaluating the all expressions wrapped in it before passing control to the error handling function. For example, the code below will try to evaluate results even though the call to odbcConnect fails. I was hoping that the mechanism would work in the same way as a C++

[R] Returning NA from lm

2009-01-23 Thread Neil Beddoe
Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2 A 4 A 6.5 ...repeat 96 times with differing values of A B 1 B 2.3 B NA B 6.5 ...repeat 96 times with

Re: [R] Returning NA from lm

2009-01-23 Thread Neil Beddoe
Beddoe Cc: r-help@r-project.org Subject: Re: [R] Returning NA from lm See ?na.exclude On Fri, 23 Jan 2009, Neil Beddoe wrote: Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2

Re: [R] Returning NA from lm

2009-01-23 Thread Neil Beddoe
If anyone's interested, I got round it by doing: tryCatch(lm(data~model,na.action=na.fail),error=function(err){NA}) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Neil Beddoe Sent: 23 January 2009 15:40 To: 'Prof Brian Ripley

Re: [R] Two Noobie questions

2009-01-07 Thread Neil Beddoe
You can also use subscripts to get at things with a bit of playing around. summary(lm(x~seq(1,length(x),1))) Call: lm(formula = x ~ seq(1, length(x), 1)) Residuals: Min 1Q Median 3Q Max -40.0961 -15.5289 -0.6489 12.7488 41.0107 Coefficients:

[R] Trouble using ohlcPlot

2009-01-06 Thread Neil Beddoe
Hi, I'm trying to create a time series that will work with ohlcPlot: mts-ts(data=c(results$OpenPrice,results$HighPrice,results$LowPrice, results$ClosePrice),c=mts,names=c(Open, High, Low,Close)) ohlcPlot(mts) fails with: Error in if ((!is.mts(x)) || (colnames(x)[1] != Open) || (colnames(x)[2]