Marie-Hélène Ouellette
2010-Aug-13 17:52 UTC
[R] Delete rpart/mvpart cross-validation output
Dear all, I was wondering if there is a simple way to avoid printing the multiple cross-validation automatic output to the console of recursive partitionning functions like rpart or mvpart. For example...> data(spider) >mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100) *X-Val rep : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Minimum tree sizes tabmins 4 6 7 8 2 18 78 2 * ... loosing what's in bold ? Thank you for your time, MH [[alternative HTML version deleted]]
On Fri, 2010-08-13 at 14:52 -0300, Marie-H?l?ne Ouellette wrote:> Dear all,I've been away for several weeks but I don't see an answer on the list so...> I was wondering if there is a simple way to avoid printing the multiple > cross-validation automatic output to the console of recursive partitionning > functions like rpart or mvpart. For example...Unfortunately, no. These messages are hardcoded in the mvpart function and printed using cat( ) calls. This is unfortunate as a verbose or trace argument and appropriate if(verbose) statements before these calls to cat would have allowed you to turn off the statements printed. One way to achieve something similar would be to use sink() and then unlink() the file to which output has been diverted. (unlinking a file deletes it.)> sink("foo.FOO") > mod <- mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100)> sink() > unlink("foo.FOO")Depends on what you had in mind and why you wanted to suppress the output. You could do fix(mvpart) and edit the function to remove the calls to cat() as required.> > data(spider) > > > mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100) > *X-Val rep : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 > 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 > 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 > 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 > 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 > 95 96 97 98 99 100 > Minimum tree sizes > tabmins > 4 6 7 8 > 2 18 78 2 * > > ... loosing what's in bold ?HTML mail is not advocated on this list, and in plain text, all the bold formatting is lost. HTH G> Thank you for your time, > MH > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On Fri, Aug 13, 2010 at 1:52 PM, Marie-H?l?ne Ouellette <marieheleneo at gmail.com> wrote:> Dear all, > > I was wondering if there is a simple way to avoid printing the multiple > cross-validation automatic output to the console of recursive partitionning > functions like rpart or mvpart. For example... > >> data(spider) >> > mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100) > *X-Val rep : 1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?10 ?11 ?12 ?13 ?14 ?15 ?16 ?17 ?18 > 19 ?20 ?21 ?22 ?23 ?24 ?25 ?26 ?27 ?28 ?29 ?30 ?31 ?32 ?33 ?34 ?35 ?36 ?37 > 38 ?39 ?40 ?41 ?42 ?43 ?44 ?45 ?46 ?47 ?48 ?49 ?50 ?51 ?52 ?53 ?54 ?55 ?56 > 57 ?58 ?59 ?60 ?61 ?62 ?63 ?64 ?65 ?66 ?67 ?68 ?69 ?70 ?71 ?72 ?73 ?74 ?75 > 76 ?77 ?78 ?79 ?80 ?81 ?82 ?83 ?84 ?85 ?86 ?87 ?88 ?89 ?90 ?91 ?92 ?93 ?94 > 95 ?96 ?97 ?98 ?99 ?100 > Minimum tree sizes > tabmins > ?4 ?6 ?7 ?8 > ?2 18 78 ?2 * > > ... loosing what's in bold ? >Try this hack: cat <- function(...) if (..1 != " " && ..1 != "X-Val rep : 1") base::cat(...) environment(mvpart) <- .GlobalEnv mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100)
Henrique Dallazuanna
2010-Aug-18 13:28 UTC
[R] Delete rpart/mvpart cross-validation output
Try this also: invisible(capture.output(x <- mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100))) x On Fri, Aug 13, 2010 at 2:52 PM, Marie-Hélène Ouellette < marieheleneo@gmail.com> wrote:> Dear all, > > I was wondering if there is a simple way to avoid printing the multiple > cross-validation automatic output to the console of recursive partitionning > functions like rpart or mvpart. For example... > > > data(spider) > > > > mvpart(data.matrix(spider[,1:12])~herbs+reft+moss+sand+twigs+water,spider,xv="1se",xvmult=100) > *X-Val rep : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 > 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 > 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 > 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 > 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 > 95 96 97 98 99 100 > Minimum tree sizes > tabmins > 4 6 7 8 > 2 18 78 2 * > > ... loosing what's in bold ? > > Thank you for your time, > MH > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]