Tony Plate
2007-Feb-20 19:14 UTC
[Rd] proposal to allow just transcript files (output only) in the 'tests' directory
Currently, as far as I can see, both input and output fles must be supplied in the 'tests' directory (the input in a '.R' file, and the output in a corresponding '.Rout.save' file.) Often, the '.R' file is redundant, as it could be reconstructed by simply stripping the commands out of the '.Rout.save' file. E.g., the command $ sed -n -e 's/^[>+] //p' ./src/library/stats/tests/nls.Rout.save produces the same R commands as in ./src/library/stats/tests/nls.R If I've missed something, and this is already supported, my apologies, & please let me know. If indeed this facility is not present, would anyone from the R core group consider an addition to allow '.Rt' (or '.Rt.save') files in the 'tests' directory? These would by just like the '.Rout.save' files, except that no corresponding '.R' file would be required -- the R commands would be extracted from them by simple line processing. Of course, '.R' and '.Rout.save' files could still be used where necessary or preferred. The primary advantage of this change would be to make it easier to add and maintain tests -- only one file would need to be created or changed, and no redundant information would be required. My view is that tests should be as easy as possible to create and maintain, and the current system adds a small amount of unnecessary difficulty. If such an addition would be considered, I would be happy to supply patches to implement it (and test them in a build under Windows & Linux). I have tested a prototype, and it seems pretty simple to add this: as far as I can see, small changes are needed in three files: ./share/make/tests.mk ./src/gnuwin32/fixed/share/tests.mk ./bin/check Please respond with comments/suggestions/corrections/pointing-out-of-gotchas/etc! thanks, Tony Plate
Bill Dunlap
2007-Feb-20 19:56 UTC
[Rd] proposal to allow just transcript files (output only) in the 'tests' directory
On Tue, 20 Feb 2007, Tony Plate wrote:> Currently, as far as I can see, both input and output fles must be > supplied in the 'tests' directory (the input in a '.R' file, and the > output in a corresponding '.Rout.save' file.) Often, the '.R' file is > redundant, as it could be reconstructed by simply stripping the commands > out of the '.Rout.save' file. E.g., the command > $ sed -n -e 's/^[>+] //p' ./src/library/stats/tests/nls.Rout.save > produces the same R commands as in ./src/library/stats/tests/nls.RSome output lines start with "+ ". E.g., in gamlss/tests/manual.Rout.save I see > mod3<-stepAIC(mod1, scope=list(lower=~1,upper=~(x1+x2+x3+x4+x5+x6)^2)) Distribution parameter: mu Start: AIC= 319.16 y ~ x1 + x2 + x3 + x4 + x5 + x6 Df AIC + x4:x5 1 307.07 + x1:x5 1 316.94 - x6 1 317.16 so R would try to parse "x4:x5 1 307.07". You could use awk so the "^+ " lines had to immediately follow "^> " (or a properly preceded "^+ "), but I suspect there will still be problems. I have experimented with similar things to compare Splus and R output for the same commands. Having the original input lines helps there. The hard part is parsing the output so it can be recognized as a matrix, a vector with names, an expression, lm() output, etc. Then I could see that the following outputs are equivalent: R : R : Call: R : lm(formula = log(x) ~ x, data = list(x = 1:10)) R : R : Coefficients: R : (Intercept) x R : 0.2432 0.2304 R : Splus: Call: Splus: lm(formula = log(x) ~ x, data = list(x = 1:10)) Splus: Splus: Coefficients: Splus: (Intercept) x Splus: 0.2432038 0.2304068 Splus: Splus: Degrees of freedom: 10 total; 8 residual Splus: Residual standard error: 0.2388027 This would also be handy for comparing results in different versions of R, where low level printing routines may be changed a bit. ---------------------------------------------------------------------------- Bill Dunlap Insightful Corporation bill at insightful dot com 360-428-8146 "All statements in this message represent the opinions of the author and do not necessarily reflect Insightful Corporation policy or position."