[Rd] help text for which.min
Dear R developers, I find the which.min function very handy. However, maybe you could consider a tiny addition to the example data in the the help text. By adding another zero to the vector x... x <- c(1:4, 0, 0:5,11) ...the example would more explicitly show that which.min actually 'giv[es] the index of the /first/ minimum or maximum respectively of x'. This will also more clearly distinguish it from which(x == min(x)) that is mentioned in the text. which.min(x) [1] 5 > which(x == min(x)) [1] 5 6 The 'first' is emphasized by italics in the Value section, while it is parenthesized in Description. I believe that the parenthesis could be removed, and 'first' possibly could be emphasized here as well. Well, well, just a small suggestion. Thank you all for your great work. Best regards, Henrik -- Henrik Pärn Centre for Conservation Biology Department of Biology Norwegian University of Science and Technology NO-7491 Trondheim NORWAY Office: +47 735 96084 Mobile: +47 909 89 255 Fax: +47 735 96100 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] help text for which.min
Of course the reasoning below applies also to an example with which.max, so yet another suggestion for the x vector: x <- c(1, 2, 0, 0, 3, 3, 1, 2) > which.min(x) [1] 3 > which(x == min(x)) [1] 3 4 > which.max(x) [1] 5 > which(x == max(x)) [1] 5 6 Cheers, Henrik On 08.10.2011 14:54, Henrik Pärn wrote: > Dear R developers, > > I find the which.min function very handy. However, maybe you could > consider a tiny addition to the example data in the the help text. > > By adding another zero to the vector x... > > x <- c(1:4, 0, 0:5,11) > > ...the example would more explicitly show that which.min actually > 'giv[es] the index of the /first/ minimum or maximum respectively of > x'. This will also more clearly distinguish it from which(x == min(x)) > that is mentioned in the text. > which.min(x) > [1] 5 > > which(x == min(x)) > [1] 5 6 > > The 'first' is emphasized by italics in the Value section, while it is > parenthesized in Description. I believe that the parenthesis could be > removed, and 'first' possibly could be emphasized here as well. > > > Well, well, just a small suggestion. Thank you all for your great work. > > Best regards, > > Henrik > > -- > Henrik Pärn > Centre for Conservation Biology > Department of Biology > Norwegian University of Science and Technology > NO-7491 Trondheim > NORWAY > > Office: +47 735 96084 > Mobile: +47 909 89 255 > Fax: +47 735 96100 -- Henrik Pärn Centre for Conservation Biology Department of Biology Norwegian University of Science and Technology NO-7491 Trondheim NORWAY Office: +47 735 96084 Mobile: +47 909 89 255 Fax: +47 735 96100 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] "What Calls What" diagram. Flow Chart?
On Sun, Oct 9, 2011 at 5:29 PM, wrote: > Hi Paul > > Have you tried > > mvbutils::foodweb( where=asNamespace( 'lavaan')) > > (assuming lavaan has a namespace, otherwise where='package:lavaan')? > > Sounds like it's what you're after-- > > Mark > Thanks, Mark. The foodweb graph for lavaan is a bit overwhelming. The graph shows everything it finds that might be called any time, it doesn't help me trace the path of a specific user call to a particular function. So I'm not entirely sure it is doing what I hope for. While matching the graph against the source code, it seems to me some R language idioms can confuse/break the foodweb. When eval is called on a string object, then I think function calls can escape detection. In the cfa example code I put in the original post, the function "lavaan" is called by eval, and as far as I can tell in the foodweb output, that connection is not found. I'm still studying your package, of course, but here's (I think) an example, I know "cfa" does call "lavaan" though eval, but this code library(lavaan) library(mvbutils) mvbutils::foodweb( where=asNamespace( 'lavaan')) myfw <- mvbutils::foodweb( where=asNamespace( 'lavaan')) callers.of("lavaan", myfw) > [1] "independence.model" "independence.model.fit" [3] "independence.model.fit2" "setLavaanOptions" -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] "What Calls What" diagram. Flow Chart?
Have you tried using trace()? E.g., > library(lavaan) > trace(lavaan) > HS.model <- ' visual =~ x1 + x2 + x3 +textual =~ x4 + x5 + x6 +speed =~ x7 + x8 + x9 ' > > fit <- cfa(HS.model, data=HolzingerSwineford1939) trace: lavaan(model.syntax = HS.model, data = HolzingerSwineford1939, model.type = "cfa", int.ov.free = TRUE, int.lv.free = FALSE, auto.fix.first = TRUE, auto.fix.single = TRUE, auto.var = TRUE, auto.cov.lv.x = TRUE, auto.cov.y = TRUE) or, to see who is calling what and what eval is evaluating, > trace(lavaan, quote(cat(sapply(sys.calls(), function(e)deparse(e)[1]), sep="\n "))) Tracing function "lavaan" in package "lavaan" [1] "lavaan" > trace(eval, quote(cat(" ", deparse(expr), "\n"))) Tracing function "eval" in package "base" [1] "eval" > HS.model <- ' visual =~ x1 + x2 + x3 +textual =~ x4 + x5 + x6 +speed =~ x7 + x8 + x9 ' > > fit <- cfa(HS.model, data=HolzingerSwineford1939) Tracing eval(mc, parent.frame()) on entry lavaan(model.syntax = HS.model, data = HolzingerSwineford1939, model.type = "cfa", int.ov.free = TRUE, int.lv.free = FALSE, auto.fix.first = TRUE, auto.fix.single = TRUE, auto.var = TRUE, auto.cov.lv.x = TRUE, auto.cov.y = TRUE) Tracing lavaan(model.syntax = HS.model, data = HolzingerSwineford1939, on entry cfa(HS.model, data = HolzingerSwineford1939) eval(mc, parent.frame()) eval(expr, envir, enclos) lavaan(model.syntax = HS.model, data = HolzingerSwineford1939, .doTrace(cat(sapply(sys.calls(), function(e) deparse(e)[1]), eval.parent(exprObj) eval(expr, p) eval(expr, envir, enclos) Tracing eval(parse(text = x)[[1L]]) on entry ~visual Tracing eval(parse(text = x)[[1L]]) on entry ~x1 + x2 + x3 Tracing eval(parse(text = x)[[1L]]) on entry ~textual Tracing eval(parse(text = x)[[1L]]) on entry ~x4 + x5 + x6 Tracing eval(parse(text = x)[[1L]]) on entry ~speed Tracing eval(parse(text = x)[[1L]]) on entry ~x7 + x8 + x9 Tracing eval(formal.args[[deparse(substitute(arg))]]) on entry c("no", "ifany", "always") Tracing eval(formal.args[[deparse(substitute(arg))]]) on entry c("shell", "quick", "radix") Tracing eval(formal.args[[deparse(substitute(arg))]]) on entry c("pearson", "kendall", "spearman") Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On > Behalf Of Paul Johnson > Sent: Monday, October 10, 2011 8:31 AM > To: mark.braving...@csiro.au; R Devel List > Subject: Re: [Rd] "What Calls What" diagram. Flow Chart? > > On Sun, Oct 9, 2011 at 5:29 PM, wrote: > > Hi Paul > > > > Have you tried > > > > mvbutils::foodweb( where=asNamespace( 'lavaan')) > > > > (assuming lavaan has a namespace, otherwise where='package:lavaan')? > > > > Sounds like it's what you're after-- > > > > Mark > > > Thanks, Mark. The foodweb graph for lavaan is a bit overwhelming. > > The graph shows everything it finds that might be called any time, it > doesn't help me trace the path of a specific user call to a particular > function. So I'm not entirely sure it is doing what I hope for. > > While matching the graph against the source code, it seems to me some > R language idioms can confuse/break the foodweb. When eval is called > on a string object, then I think function calls can escape detection. > In the cfa example code I put in the original post, the function > "lavaan" is called by eval, and as far as I can tell in the foodweb > output, that connection is not found. > > I'm still studying your package, of course, but here's (I think) an > example, I know "cfa" does call "lavaan" though eval, but this code > > library(lavaan) > library(mvbutils) > mvbutils::foodweb( where=asNamespace( 'lavaan')) > > myfw <- mvbutils::foodweb( where=asNamespace( 'lavaan')) > > callers.of("lavaan", myfw) > > > > [1] "independence.model" "independence.model.fit" > [3] "independence.model.fit2" "setLavaanOptions" > > > > > -- > Paul E. Johnson > Professor, Political Science > 1541 Lilac Lane, Room 504 > University of Kansas > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] "Speeding tickets for R and Stata"
Hello, an article on that topic: http://ekonometrics.blogspot.com/2011/04/speeding-tickets-for-r-and-stata.html Ciao, Oliver __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R CMD INSTALL writes to stderr
Dear list, (this is a follow up from a previous query) Why does R CMD INSTALL write most of its messages to stderr? If it wrote to stdout, then we could capture its output within an R session when calling sink("stdout.txt", type="output") install.packages("MASS", type="source") sink() As it stands, the stderr messages can't be captured via sink/capture.output/suppressMessages within an R session. Interestingly, the make output goes to stdout, but the R messages go to stderr: # the 'make' output goes to stdout $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz 2>/dev/null gcc-4.2 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c MASS.c -o MASS.o gcc-4.2 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c lqs.c -o lqs.o gcc-4.2 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o MASS.so MASS.o lqs.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include-fPIC -g -O2 -c MASS.c -o MASS.o gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include-fPIC -g -O2 -c lqs.c -o lqs.o gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o MASS.so MASS.o lqs.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation # the R CMD INSTALL output goes to stderr $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz >/dev/null * installing *source* package MASS ... ** libs *** arch - i386 installing to /private/tmp/MASS/libs/i386 *** arch - x86_64 installing to /private/tmp/MASS/libs/x86_64 ** R ** data ** moving datasets to lazyload DB ** inst ** preparing package for lazy loading ** help *** installing help indices ** building package indices ... ** testing if installed package can be loaded * DONE (MASS) $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz &>/dev/null # no output Why do I care? i'm writing some software which uses R behind the scenes, and would like to suppress the messages that are produced by install.packages() when R libraries are being installed. So, will it be possible for R CMD INSTALL output be written to stdout in the future? kind regards, Mark - Mark Cowley, PhD Pancreatic Cancer Program | Peter Wills Bioinformatics Centre Garvan Institute of Medical Research, Sydney, Australia - sessionInfo() R version 2.13.1 (2011-07-08) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD INSTALL writes to stderr
On Oct 10, 2011, at 8:48 PM, Mark Cowley wrote: > Dear list, > (this is a follow up from a previous query) > > Why does R CMD INSTALL write most of its messages to stderr? If it wrote to > stdout, then we could capture its output within an R session when calling > sink("stdout.txt", type="output") > install.packages("MASS", type="source") > sink() > > As it stands, the stderr messages can't be captured via > sink/capture.output/suppressMessages within an R session. Interestingly, the > make output goes to stdout, but the R messages go to stderr: > > # the 'make' output goes to stdout > $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz 2>/dev/null > gcc-4.2 -arch i386 -std=gnu99 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 > -I/usr/local/include-fPIC -g -O2 -c MASS.c -o MASS.o > gcc-4.2 -arch i386 -std=gnu99 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/i386 > -I/usr/local/include-fPIC -g -O2 -c lqs.c -o lqs.o > gcc-4.2 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names > -undefined dynamic_lookup -single_module -multiply_defined suppress > -L/usr/local/lib -o MASS.so MASS.o lqs.o -F/Library/Frameworks/R.framework/.. > -framework R -Wl,-framework -Wl,CoreFoundation > gcc-4.2 -arch x86_64 -std=gnu99 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/x86_64 > -I/usr/local/include-fPIC -g -O2 -c MASS.c -o MASS.o > gcc-4.2 -arch x86_64 -std=gnu99 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/x86_64 > -I/usr/local/include-fPIC -g -O2 -c lqs.c -o lqs.o > gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names > -undefined dynamic_lookup -single_module -multiply_defined suppress > -L/usr/local/lib -o MASS.so MASS.o lqs.o -F/Library/Frameworks/R.framework/.. > -framework R -Wl,-framework -Wl,CoreFoundation > > # the R CMD INSTALL output goes to stderr > $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz >/dev/null > * installing *source* package ŒMASS‚ ... > ** libs > *** arch - i386 > installing to /private/tmp/MASS/libs/i386 > *** arch - x86_64 > installing to /private/tmp/MASS/libs/x86_64 > ** R > ** data > ** moving datasets to lazyload DB > ** inst > ** preparing package for lazy loading > ** help > *** installing help indices > ** building package indices ... > ** testing if installed package can be loaded > > * DONE (MASS) > > $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz &>/dev/null > # no output > > Why do I care? i'm writing some software which uses R behind the scenes, and > would like to suppress the messages that are produced by install.packages() > when R libraries are being installed. > > So, will it be possible for R CMD INSTALL output be written to stdout in the > future? > It can simply with 2>&1 I agree that this doesn't help you with install.packages directly. There are various degrees of ugliness that you can apply - ranging from using INSTALL_opts to force routing to stdout, to using your own system() front-end to handle the details yourself. Why you don't simply use a variation of system("R -e 'install.packages(...)'", ...) where you have full control over the routing and yet sill use install.packages? That is generally how custom installers do this ... It sort of seems what you are trying to do anyway since you don't want the internal R output ... Cheers, Simon > kind regards, > Mark > > > - > Mark Cowley, PhD > > Pancreatic Cancer Program | Peter Wills Bioinformatics Centre > Garvan Institute of Medical Research, Sydney, Australia > - > > sessionInfo() > R version 2.13.1 (2011-07-08) > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) > > locale: > [1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD INSTALL writes to stderr
Thanks for the tip Simon, i've just written a simplified version of install.packages -- install.package.file which will silently R CMD INSTALL a package, assuming you've already downloaded it & if there's an installation problem, the R CMD INSTALL output is spat to stderr. Code available if anyone's interested cheers, Mark On 11/10/2011, at 12:23 PM, Simon Urbanek wrote: > > On Oct 10, 2011, at 8:48 PM, Mark Cowley wrote: > >> Dear list, >> (this is a follow up from a previous query) >> >> Why does R CMD INSTALL write most of its messages to stderr? If it wrote to >> stdout, then we could capture its output within an R session when calling >> sink("stdout.txt", type="output") >> install.packages("MASS", type="source") >> sink() >> >> As it stands, the stderr messages can't be captured via >> sink/capture.output/suppressMessages within an R session. Interestingly, the >> make output goes to stdout, but the R messages go to stderr: >> >> # the 'make' output goes to stdout >> $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz 2>/dev/null >> gcc-4.2 -arch i386 -std=gnu99 >> -I/Library/Frameworks/R.framework/Resources/include >> -I/Library/Frameworks/R.framework/Resources/include/i386 >> -I/usr/local/include-fPIC -g -O2 -c MASS.c -o MASS.o >> gcc-4.2 -arch i386 -std=gnu99 >> -I/Library/Frameworks/R.framework/Resources/include >> -I/Library/Frameworks/R.framework/Resources/include/i386 >> -I/usr/local/include-fPIC -g -O2 -c lqs.c -o lqs.o >> gcc-4.2 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names >> -undefined dynamic_lookup -single_module -multiply_defined suppress >> -L/usr/local/lib -o MASS.so MASS.o lqs.o >> -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework >> -Wl,CoreFoundation >> gcc-4.2 -arch x86_64 -std=gnu99 >> -I/Library/Frameworks/R.framework/Resources/include >> -I/Library/Frameworks/R.framework/Resources/include/x86_64 >> -I/usr/local/include-fPIC -g -O2 -c MASS.c -o MASS.o >> gcc-4.2 -arch x86_64 -std=gnu99 >> -I/Library/Frameworks/R.framework/Resources/include >> -I/Library/Frameworks/R.framework/Resources/include/x86_64 >> -I/usr/local/include-fPIC -g -O2 -c lqs.c -o lqs.o >> gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names >> -undefined dynamic_lookup -single_module -multiply_defined suppress >> -L/usr/local/lib -o MASS.so MASS.o lqs.o >> -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework >> -Wl,CoreFoundation >> >> # the R CMD INSTALL output goes to stderr >> $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz >/dev/null >> * installing *source* package ŒMASS‚ ... >> ** libs >> *** arch - i386 >> installing to /private/tmp/MASS/libs/i386 >> *** arch - x86_64 >> installing to /private/tmp/MASS/libs/x86_64 >> ** R >> ** data >> ** moving datasets to lazyload DB >> ** inst >> ** preparing package for lazy loading >> ** help >> *** installing help indices >> ** building package indices ... >> ** testing if installed package can be loaded >> >> * DONE (MASS) >> >> $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz &>/dev/null >> # no output >> >> Why do I care? i'm writing some software which uses R behind the scenes, and >> would like to suppress the messages that are produced by install.packages() >> when R libraries are being installed. >> >> So, will it be possible for R CMD INSTALL output be written to stdout in the >> future? >> > > It can simply with 2>&1 > > I agree that this doesn't help you with install.packages directly. There are > various degrees of ugliness that you can apply - ranging from using > INSTALL_opts to force routing to stdout, to using your own system() front-end > to handle the details yourself. > > Why you don't simply use a variation of system("R -e > 'install.packages(...)'", ...) where you have full control over the routing > and yet sill use install.packages? That is generally how custom installers do > this ... It sort of seems what you are trying to do anyway since you don't > want the internal R output ... > > Cheers, > Simon > > >> kind regards, >> Mark >> >> >> - >> Mark Cowley, PhD >> >> Pancreatic Cancer Program | Peter Wills Bioinformatics Centre >> Garvan Institute of Medical Research, Sydney, Australia >> - >> >> sessionInfo() >> R version 2.13.1 (2011-07-08) >> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) >> >> locale: >> [1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8 >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> >> [[alternative HTML version deleted]] >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mail