gtools/0000755000176000001440000000000012265000227011605 5ustar ripleyusersgtools/inst/0000755000176000001440000000000012264336050012567 5ustar ripleyusersgtools/inst/NEWS0000644000176000001440000001120612264352677013303 0ustar ripleyusersgtools 3.2.0 - 2014-01-11 ------------------------- New features: - The keywords() function now accepts a function or function name as an argument and will return the list of keywords associated with the named function. - New function stars.pval() which will generate p-value significance symbols ('***', '**', etc.) Bug fixes: - R/mixedsort.R: mixedorder() was failing to correctly handle numbers including decimals due to a faulty regular expression. Other changes: - capture() and sprint() are now defunct. gtools 3.1.1 - 2013-11-06 ------------------------- Bug fixes: - Fix problem with mixedorder/mixedsort when there is zero or one elements in the argument vector. gtools 3.1.0 - 2013-09-22 ------------------------- Major changes: - The function 'addLast()' (deprecated since gtools 3.0.0) is no longer available, and has been marked defunct. Bug fixes: - Modified 'mixedorder()' to use Use 'suppressWarnings() instead of 'options(warn=-1)'. This will avoid egregious warning messages when called from within a nested environment, such as when run from within 'knitr' gtools 3.0.0 - 2013-07-06 ------------------------- Major changes: - The function 'addLast()' has been deprecated because it directly manipulates the global environment, which is expressly prohibited by the CRAN policies. - A new function, 'lastAdd()' has been created to replace 'addLast()'. The name has been changed because the two functions require different syntax. 'addLast()' was used like this: byeWorld <- function() cat("\nGoodbye World!\n") addLast(byeWorld) The new 'lastAdd()' function is used like this: byeWorld <- function() cat("\nGoodbye World!\n") .Last <- lastAdd(byeWorld) Bug fixes: - Update checkRVersion() to work with R version 3.0.0 and later. Other changes: - Remove cross-reference to (obsolete?) moc package - The function 'assert()' (deprecated since gtools 2.5.0) is no longer available and has been marked defunct. gtools 2.7.1 - 2013-03-17 ------------------------- Bug fixes: - smartbind() was not properly handling factor columns when the first data frame did not include the relevant column. gtools 2.7.0 - 2012-06-19 ------------------------- New features: - smartbind() has a new 'sep' argument to allow specification of the character(s) used to separate components of constructed column names - smartbind() has a new 'verbose' argument to provide details on how coluumns are being processed Bug fixes: - smartbind() has been enhanced to improve handling of factor and ordered factor columns. gtools 2.6.2 - 2011-09-28 ------------------------- New features: - Add 'fill' argument to smartbind() to specify a value to use for missing entries. gtools 2.6.1 ------------ New features: - Add newVersionAvailable() function to compare running and latest available R versions. - Add keywords() function to show $RHOME/doc/KEYWORDS file Bug fixes: - Correct windows make flags as suggested by Brian Ripley. - Update Greg's email address and fix Rd syntax errors gtools 2.5.0 ------------ New features: - Add checkRVersion() function to determin if a newer version of R is available. - Deprecated assert() in favor of base::stopifnot Bug fixes: - Fix bug in binsearch() identified by 2.6.0 R CMD CHECK Other changes: - Improve text explanation of how defmacro() and strmacro() differ from function(). - Update definitions of odd() and even() to use modulus operator instead of division. gtools 2.4.0 ------------ - Add binsearch() function, previously in the genetics() package. gtools 2.3.1 ------------ - Add ask() function to prompt the user and collect a single response. gtools 2.3.0 ------------ - Update email address for Greg - Add new 'smartbind' function, which combines data frames efficiently, even if they have different column names. gtools 2.2.3 ------------ - setTCPNoDelay now compiles & works properly on Windows gtools 2.2.2 ------------ - src/setTCPNoDelay.c: Add C source code for setTCPNoDelay. - NAMESPACE: Add UseDynLib to NAMESPACE so the shared library gets properly loaded. - Updated Greg's email address. gtools 2.2.1 ------------ - New function 'addLast' that adds functions to R's .Last() so that they will be executed when R is terminating. - New function setTCPNoDelay() that allows the TCP_NODELAY flag to be changed on socket objects. gtools 2.1.0 ------------ - Added assert.R (and documentation) - Added the defmacro() function, extracted from Lumley T. "Programmer's Niche: Macros in {R}", R News, 2001, Vol 1, No. 3, pp 11--13, \url{http://CRAN.R-project.org/doc/Rnews/} - Added DESCRIPTION and removed DESCRIPTION.in gtools/inst/ChangeLog0000644000176000001440000005620312264352252014351 0ustar ripleyusers2014-01-11 warnes * [r1762] DESCRIPTION, NAMESPACE, R/capture.R, R/defunct.R, R/keywords.R, man/capture.Rd, man/gtools-defunct.Rd, man/stars.pval.Rd: Fixes for gtools release 3.2.0 2013-12-23 warnes * [r1761] R/keywords.R, man/keywords.Rd: Extend the keywords() function to return keywords associated with a specified topic via 'keywords(topic)'. * [r1760] man/stars.pval.Rd: Add keyword. * [r1759] NAMESPACE, R/stars.pval.R, man/stars.pval.Rd: Add stars.pval() function to convert p-values into significance symbols. 2013-11-26 warnes * [r1748] R/mixedsort.R: mixedorder() was failing to correctly handle numbers including decimals due to a faulty regular expression. Prior to the fix: > drr [1] "Dose 0.3 mg" "Dose 0.04 mg" "Dose 0.5 mg" > gtools::mixedsort(drr) [1] "Dose 0.3 mg" "Dose 0.04 mg" "Dose 0.5 mg" After the fix: > drr [1] "Dose 0.3 mg" "Dose 0.04 mg" "Dose 0.5 mg" > mixedsort(drr) [1] "Dose 0.04 mg" "Dose 0.3 mg" "Dose 0.5 mg" In addition, an optimization was added that checked if the input vector was numeric. If so, simply use the existing base::order function. 2013-11-18 warnes * [r1747] R/capture.R: Use ".Deprecated" instead of warning. 2013-11-06 warnes * [r1746] DESCRIPTION, inst/NEWS: Update files for gtools 3.1.1 * [r1745] R/mixedsort.R: Fix problem with mixedorder/mixedsort when there is only zero or one elements in the vector. 2013-09-23 warnes * [r1716] man/gtools-deprecated.Rd: Comment out empty sections in gtools-deprecated.Rd * [r1715] DESCRIPTION, inst/NEWS: Update files for gtools 3.1.0 release * [r1714] man/addLast-deprecated.Rd, man/gtools-defunct.Rd, man/gtools-deprecated.Rd, man/lastAdd.Rd: Make 'addLast()' defunct. * [r1713] R/addLast.R, R/lastAdd.R: Mark 'addLast()' as defunct and move 'lastAdd()' function to a separate file. * [r1712] DESCRIPTION, inst/NEWS: Update for gtools 3.0.1 release * [r1711] R/mixedsort.R: Use 'suppressWarnings() instead of 'options(warn=-1)' in 'mixedorder()'. 2013-07-07 warnes * [r1705] man/lastAdd.Rd: Fix typo. 2013-07-06 warnes * [r1704] man/lastAdd.Rd: Fix Rd warning. * [r1703] NAMESPACE: Include lastAdd in NAMESPACE * [r1702] R/deprecated.R: Change assert from deprecated to defunct. * [r1701] R/addLast.R: Improve deprecation message * [r1700] DESCRIPTION, inst/NEWS: Update for gtools 3.0.0 * [r1699] R/addLast.R, man/addLast-deprecated.Rd, man/addLast.Rd, man/gtools-defunct.Rd, man/gtools-deprecated.Rd, man/lastAdd.Rd: Create new function lastAdd to replace addLast and mark addLast as deprecated. 2013-07-05 warnes * [r1698] inst/NEWS: Point out that addLast() modifies the value of .Last in the global environment. * [r1697] man/addLast.Rd: Point out that addLast() modifies the value of .Last in the global environment. * [r1696] DESCRIPTION, inst/NEWS: Update for gtools 2.7.2 mark 2 * [r1695] man/logit.Rd: Remove cross-reference to (obsolete?) moc package * [r1694] DESCRIPTION, inst/NEWS: Update for gtools 2.7.2 * [r1693] R/checkRVersion.R: Update for R version 3.0.0 and later 2013-03-17 warnes * [r1640] R/smartbind.R: Fix error in smartbind: factor levels were not being handled if the factor column was not present in the first data frame. 2012-06-19 warnes * [r1570] DESCRIPTION, inst/NEWS: Update for gtools 2.7.0. * [r1569] man/smartbind.Rd: Document new 'verbose' argument to smartbind(). * [r1568] R/addLast.R, R/running.R: Clean up R CMD check warnings. 2012-05-04 warnes * [r1529] R/smartbind.R: smartbind(): Improve handling of factors and ordered factors. 2011-10-05 warnes * [r1518] DESCRIPTION: Update version number for release * [r1517] R/smartbind.R, man/smartbind.Rd: Add 'sep' argument to smartbind() to allow specification of character used to separate components of constructed names 2011-09-28 warnes * [r1513] R/smartbind.R: smartbind(): Prevent coersion to data frame from mangling column names. * [r1512] R/smartbind.R, inst/NEWS: Add 'fill' argument to smartbind() to specify a value to use for missing entries. * [r1511] DESCRIPTION, man/smartbind.Rd: Add 'fill' argument to smartbind() to specify a value to use for missing entries. 2010-08-14 warnes * [r1451] R/mixedsort.R: Modify mixedorder()/mixedsort() to better handle strings containing multiple periods, like version numbers (e.g 1.1.2, 1.2.1. 1.1.1.1). 2010-05-01 warnes * [r1434] DESCRIPTION: Update version number for new release * [r1433] DESCRIPTION, man/addLast.Rd, man/ask.Rd, man/binsearch.Rd, man/capture.Rd, man/combinations.Rd, man/defmacro.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/invalid.Rd, man/keywords.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd, man/setTCPNoDelay.Rd, man/smartbind.Rd: Change Greg's email address to greg@warnes.net * [r1432] R/checkRVersion.R: Fix error in checkRVersion() 2010-04-28 ggrothendieck2 * [r1431] R/quantcut.R, R/strmacro.R, man/binsearch.Rd, man/capture.Rd, man/setTCPNoDelay.Rd: fixed problems with R CMD CHECK 2009-05-09 warnes * [r1328] man/keywords.Rd: Escape $ in .Rd file to avoid latex issues * [r1327] ChangeLog, NEWS, inst/NEWS: Update NEWS and create softlinks for NEWS and ChangeLog in top level directory * [r1326] NEWS, inst, inst/NEWS: Move actual NEWS file into inst. * [r1325] DESCRIPTION, man/addLast.Rd, man/binsearch.Rd, man/capture.Rd, man/combinations.Rd, man/defmacro.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/gtools-deprecated.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd, man/setTCPNoDelay.Rd, man/smartbind.Rd: Update Greg's email address and fix Rd syntax errors 2009-02-16 warnes * [r1313] src/Makevars.win: Correct windows make flags as suggested by Brian Ripley. 2008-08-15 warnes * [r1303] DESCRIPTION, NAMESPACE, R/keywords.R, man/keywords.Rd: Add keywords() function to show /doc/KEYWORDS file 2008-05-29 warnes * [r1285] R/newVersionAvailable.R: Add newVersionAvailable() function to compare running and latest available R versions 2008-05-26 warnes * [r1284] DESCRIPTION: Update license specification * [r1283] man/assert-deprecated.Rd: Remove 'assert' man page 2008-05-22 warnes * [r1282] man/assert.R: Finish rename of assert.R to assert-depricated.Rd * [r1281] R/checkRVersion.R: Add checkRVersion.R file * [r1280] man/assert-deprecated.Rd: Rename again to get correct extension! * [r1279] NEWS: Update NEWS for 2.5.0 * [r1278] man/checkRVersion.Rd: Add man page for checkRVersion * [r1277] man/assert-deprecated.R, man/assert.R: Rename assert-deprecated.R to assert.R to meet R file name requirements. * [r1276] DESCRIPTION, NAMESPACE: Add checkRVersion to NAMESPACE, and increment version in DESCRIPTION. * [r1275] man/gtools-deprecated.Rd: Remove broken SEE LSO reference 2008-04-12 warnes * [r1259] man/defmacro.Rd: Improve text explanation of how defmacro() and strmacro() differ from function(). * [r1258] NEWS, man/assert-deprecated.R, man/assert.Rd, man/gtools-deprecated.Rd: assert() is now deprecated in favor of base::stopifnot() * [r1257] R/assert.R, R/deprecated.R: Rename 'assert.R' to 'deprecated.R'. * [r1256] R/assert.R: Assert is now deprecated in favor of base::stopifnot(), so add call to .Deprecated() to inform the user. 2007-11-30 warnes * [r1228] R/oddeven.R: Update defnitions of odd() and even() to use modulus operator instead of division. Prettier, I think, :-D 2007-08-08 warnes * [r1121] DESCRIPTION, R/binsearch.R: Fix bug identified by R-2.6's check routings in binsearch() * [r1120] DESCRIPTION, NAMESPACE, NEWS, R/binsearch.R, man/binsearch.Rd: Add the binsearch(), previously in the genetics package. 2007-07-18 ggorjan * [r1100] man/combinations.Rd: typo fixed 2007-04-12 warnes * [r1088] NAMESPACE, NEWS, R/ask.R, man/ask.Rd: Add ask() function to prompt the user and collect a single response. 2007-04-07 warnes * [r1087] DESCRIPTION, R/mixedsort.R: Fix improper escapes in regexp detected by R 2.5.0 package check. 2007-03-23 warnes * [r1083] R/combinations.R: Allow permutations for r>n provided repeats.allowed=TRUE 2006-11-28 warnes * [r1023] man/smartbind.Rd: Replace F with FALSE in smartbind example. 2006-11-27 warnes * [r1022] man/smartbind.Rd: Replace T with TRUE in smartbind example * [r1021] data/ELISA.rda: Temprary remove to reset binary flag * [r1020] data/ELISA.rda: Temprary remove to reset binary flag * [r1019] DESCRIPTION, NAMESPACE, NEWS, R/smartbind.R, man/smartbind.Rd: Add smartbind() to list of exported functions, and add corresponding documentation file. * [r1018] DESCRIPTION: Update my email address 2006-11-14 ggorjan * [r1012] R/combinations.R, R/running.R, man/ELISA.Rd, man/combinations.Rd: Removed executable property 2006-08-02 warnes * [r977] man/addLast.Rd, man/assert.Rd, man/capture.Rd, man/combinations.Rd, man/defmacro.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd, man/setTCPNoDelay.Rd: Update my email address 2006-05-05 nj7w * [r958] man/combinations.Rd: Fixed minor typo - in {value} - n was replaced by r * [r957] NAMESPACE, man/capture.Rd: Fixed minor typos 2006-03-01 warnes * [r903] R/smartbind.R: Add smartbind function 2006-01-18 warnes * [r845] man/mixedsort.Rd: Add concept tags to make mixedsort easier to locate. 2005-12-21 warnes * [r837] DESCRIPTION: Update version number and date * [r836] NEWS: Note changes for 2.2.3 * [r835] src/Makevars.win, src/setTCPNoDelay.c: Should now work on Windows 2005-12-20 warnes * [r834] src/setTCPNoDelay.c: Temporary fix to allow setTCPNoDelay.c to compile on Windows. If compiled on windows calling setTCPNoDelay will just raise an error. 2005-12-14 warnes * [r813] src/setTCPNoDelay.c: Change C++ comment to standard comment 2005-12-13 nj7w * [r810] ChangeLog: *** empty log message *** * [r809] NEWS: Updated NEWS and removed ChangeLog 2005-12-12 nj7w * [r800] DESCRIPTION: Updated version for CRAN release 2005-12-08 warnes * [r790] src, src/setTCPNoDelay.c: Add C source code for setTCPNoDelay. 2005-12-01 nj7w * [r776] man/combinations.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/quantcut.Rd, man/running.Rd: Updated Greg's email address 2005-11-29 warnes * [r769] NAMESPACE: Add UseDynLib to NAMESPACE so the shared library gets properly loaded. * [r768] R/setTCPNoDelay.R: - Remove debugging comments - Change return value on success to "Success". 2005-11-22 warnes * [r758] NAMESPACE: NAMESPACE * [r757] NEWS: Update news for 2.2.1 release. * [r756] man/addLast.Rd, man/setTCPNoDelay.Rd: Fixes for R CMD check * [r755] DESCRIPTION, NAMESPACE, R/setTCPNoDelay.R, man/setTCPNoDelay.Rd: Add setTCPNoDelay() function and documentation * [r745] R/addLast.R, man/addLast.Rd: New function 'addLast' that adds functions to R's .Last() so that they will be executed when R is terminating. 2005-09-22 warnes * [r678] DESCRIPTION, NAMESPACE, man/defmacro.Rd: More changes for strmacro(), also changes for 2.1.1 release * [r677] R/defmacro.R, R/strmacro.R, man/defmacro.Rd: Add strmaco() which defines functions that use strings for macro definition 2005-09-21 warnes * [r676] DESCRIPTION, R/defmacro.R, man/defmacro.Rd: Add support for DOTS/... arguments to defmacro 2005-09-12 nj7w * [r671] man/assert.Rd, man/dirichlet.Rd, man/permute.Rd, man/scat.Rd: Updated Greg's email 2005-09-02 nj7w * [r653] NAMESPACE: Exported assert * [r652] DESCRIPTION: Updated the version number * [r651] NEWS: Added NEWS * [r650] ChangeLog: Added ChangeLog * [r649] man/assert.Rd: Fixed syntax errors 2005-09-02 warnes * [r648] R/assert.R, man/assert.Rd: Add assert() and documentation * [r647] man/defmacro.Rd: Fix problem in defmacro.Rd file: don't use \code{} in the example section. 2005-08-31 warnes * [r645] DESCRIPTION, NAMESPACE, R/defmacro.R, man/defmacro.Rd: Adding the defmacro() function, extracted from Lumley T. "Programmer's Niche: Macros in {R}", R News, 2001, Vol 1, No. 3, pp 11--13, \url{http://CRAN.R-project.org/doc/Rnews/} * [r642] DESCRIPTION, DESCRIPTION.in: Add stand-alone DESCRIPTION file and remove old DESCRIPTION.in file. 2005-06-13 nj7w * [r626] R/mixedsort.R: Fixed a bug in mixedsort - check if "which.na" and "which.blank" is numeric(0) before subsetting the datasets. 2005-06-09 nj7w * [r625] R/RSCompat.S, R/combinations.R, R/dirichlet.R, R/foldchange.R, R/invalid.R, R/logit.R, R/mixedsort.R, R/oddeven.R, R/permute.R, R/quantcut.R, R/running.R, R/scat.R, man/ELISA.Rd, man/combinations.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd: Updating the version number, and various help files to synchronize splitting of gregmisc bundle in 4 individual components. 2005-05-10 warnes * [r619] R/mixedsort.R: Fix handling of NA's in mixedorder. We were using a high UTF character to try to put NA's at the end of the sort order, but R 2.1.0 checks if characters are in the correct range. Instead, we explicitly force NA's to the end. 2005-04-07 warnes * [r606] NAMESPACE, R/scat.R, man/scat.Rd: - Add scat() function which writes its arguments to stderr and flushes so that output is immediately displayed, but only if 'getOption("DEBUG")' is true. 2005-04-02 warnes * [r600] NAMESPACE, R/drop.levels.R, man/drop.levels.Rd: Move drop.levels() from gtools to gdata. * [r599] R/mixedsort.R: Minor reordering of functions in file * [r598] NAMESPACE, R/frameApply.R, man/frameApply.Rd: Move frameApply() to gdata package. * [r597] R/mixedsort.R: Fix error if only one value passed to mixedorder. * [r596] R/quantcut.R, man/quantcut.Rd: Add proper handling where more than one quantile obtains the same value 2005-04-01 warnes * [r595] man/ELISA.Rd, man/combinations.Rd, man/dirichlet.Rd, man/drop.levels.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd: Add CVS ID tag to file headers. * [r594] R/frameApply.R, man/frameApply.Rd: Fixes from Jim Rogers for R CMD check problems in frameApply 2005-03-31 warnes * [r591] R/drop.levels.R, R/frameApply.R, man/drop.levels.Rd, man/frameApply.Rd: Updates to drop.levels() and frameApply() from Jim Rogers * [r590] data, data/ELISA.rda, man/ELISA.Rd: Add ELISA data set used by frameApply and drop.levels examples 2005-02-25 warnes * [r562] man/frameApply.Rd: Replace 'T' with TRUE. * [r561] man/frameApply.Rd: Remove dependency on ELISA data set for the example. * [r558] NAMESPACE: Add drop.levels, frameApply to namespace export. 2005-02-15 warnes * [r542] R/drop.levels.R, R/frameApply.R, man/drop.levels.Rd, man/frameApply.Rd: Add frameApply and drop.levels contributed by Jim Rogers. 2005-01-12 warnes * [r515] DESCRIPTION.in: Add dependency on R 1.9.0+ to prevent poeple from installing on old versions of R which don't support namespaces. 2004-09-27 warneg * [r461] DESCRIPTION, DESCRIPTION.in, man/running.Rd: Updated to pass R CMD check. 2004-09-03 warneg * [r446] DESCRIPTION, NAMESPACE, R/dirichlet.R, R/foldchange.R, R/invalid.R, R/mixedsort.R, R/oddeven.R, R/permute.R, R/quantcut.R, R/running.R, man/running.Rd: initial bundle checkin 2004-09-02 warneg * [r442] DESCRIPTION, DESCRIPTION.in, NAMESPACE: Initial revision 2004-08-27 warnes * [r441] R/mixedsort.R, man/mixedsort.Rd: Fixed bug in mixedsort, and modified reorder.factor to use mixedsort. 2004-08-26 warnes * [r440] R/mixedsort.R: - Fix bug pointed out by Jim Rogers. - Use a more distictive internal separator: $@$ instead of just $ - Capitalization is now irrelevent for search order (unlike ASCII). 2004-06-08 warnes * [r372] R/running.R, man/running.Rd: Nitin Jain added by= parameter to allow specifying separation between groups. 2004-05-26 warnes * [r345] man/combinations.Rd: Escape underscores in email addresses so Latex is happy. * [r343] R/combinations.R: Replace 'T' with 'TRUE' to pass R CMD check. 2004-05-25 warnes * [r334] R/combinations.R: Remove extraneous comments. * [r333] R/combinations.R: Fix an error in the code when using repeats.allow=T and r>2. Bug report and fix both due to Elizabeth Purdom . 2004-05-24 warnes * [r323] R/invalid.R: Check if argument is a vector before doing is.na to avoid generating a warning. * [r322] R/invalid.R, man/invalid.Rd: Add invalid() function for testing if a parameter value is non-missing, non-NA, non-NULL. 2004-04-27 warnes * [r321] R/running.R, man/running.Rd: Replaced argument `as.list' with `simplify'. Updated documentation, and updated examples appropriately. 2004-04-26 warnes * [r320] R/running.R, man/running.Rd: Added as.list argument to return one list element per evaluation. 2004-03-26 warnes * [r303] man/combinations.Rd: Uncomment and fix large 'n' example. * [r301] man/running.Rd: - Update to match changes in running() - Add examples to illustrate new arguments. - Modify running correlation plot example to be more clear. * [r299] R/running.R: More of the same. * [r297] R/running.R: Fix bug discovered by Sean Davis . The running function took an improper shortcut. When allow.fewer=FALSE it was still passing shorter lists of elements to the called function, and then overwriting the results for the shorter lists with NAs. The code now skips evaluation of the function on lists shorter than the specified length when allow.fewer=FALSE. 2004-01-21 warnes * [r277] R/capture.R: - Mark sprint() as depreciated. - Replace references to sprint with capture.output() - Use match.arg for halign and valign arguments to textplot.default. - Fix textplot.character so that a vector of characters is properly displayed. Previouslt, character vectors were plotted on top of each other. 2003-12-03 warnes * [r253] man/foldchange.Rd: - match function argument defaults with 'usage' 2003-11-21 warnes * [r237] man/foldchange.Rd: Removed 'deqn' call that was confusing things. * [r234] man/logit.Rd: Add email address to author field * [r233] R/foldchange.R, man/foldchange.Rd: - new files * [r232] R/mixedsort.R, man/mixedsort.Rd: - Change 'T' to 'TRUE' in mixedsort.R - Add missing brace in mixedsort.Rd 2003-11-20 warnes * [r230] R/oddeven.R, man/oddeven.Rd: - Move 'odd' and 'even' functions to a separate file & provide documentation 2003-11-18 warnes * [r227] R/mixedsort.R, man/mixedsort.Rd: - Renamed smartsort to mixedsort and added documentation. 2003-11-10 warnes * [r220] R/capture.R, man/capture.Rd: - Add files contributed by Arni Magnusson . As well as some of my own. 2003-05-23 warnes * [r196] R/logit.R, man/logit.Rd: - library() backported from 1.7-devel. This version of the function adds the "pos=" argument to specify where in the search path the library should be placed. - updated .First.lib to use library(...pos=3) for MASS to avoid the 'genotype' data set in MASS from masking the genotype funciton in genetics when it loads gregmisc - Added logit() inv.logit() matchcols() function and corresponding docs 2003-04-22 warnes * [r189] man/combinations.Rd: - Fixed tpyo in example that allowed combinations(500,2) to run when it should have been ignred for testing.. 2003-04-10 warnes * [r186] man/combinations.Rd: - Added note about the need to increase options("expressions") to use large values for 'n'. Prompted by bug report from Huan Huang n provided repeat.allowed=TRUE - Bumped up version number 2002-08-01 warnes * [r114] R/running.R: - Corrected documentation mismatch for ci, ci.default. - Replaced all occurences of '_' for assignment with '<-'. - Replaced all occurences of 'T' or 'F' for 'TRUE' and 'FALSE' with the spelled out version. - Updaded version number and date. 2002-04-09 warneg * [r109] R/combinations.R, man/combinations.Rd, man/running.Rd: Checkin for version 0.5.3 2002-03-26 warneg * [r97] man/quantcut.Rd: Initial Checkin * [r96] R/quantcut.R: Initial checkin. 2002-03-20 warneg * [r91] R/RSCompat.S: - Added definition of is.R function. - Added boxplot.formula 2002-03-07 warneg * [r90] man/running.Rd: - Added documentation and example for running2 * [r89] R/running.R: - Added "running2", which handles both univariate and bivariate cases - Modified "running" to call "running2" 2002-02-05 warneg * [r75] R/RSCompat.S: - Fix typo that caused code meant to run only under S-Plus to run under R, causing problems. 2001-12-19 warneg * [r67] R/RSCompat.S: - Added code for %in%. 2001-09-18 warneg * [r18] R/RSCompat.S: Release 0.3.2 2001-09-01 warneg * [r17] R/RSCompat.S: Initial checkin. * [r16] R/running.R, man/running.Rd: Release 0.3.0 2001-08-25 warneg * [r13] R/running.R: Initial CVS checkin. * [r11] man/combinations.Rd: Fixed a typo and a syntax error. * [r7] man/running.Rd: Initial Checkin 2001-06-29 warneg * [r6] ., R, R/combinations.R, man, man/combinations.Rd: Initial revision. gtools/src/0000755000176000001440000000000012264771430012406 5ustar ripleyusersgtools/src/setTCPNoDelay.c0000644000176000001440000000744112264771430015176 0ustar ripleyusers#include #include # include #ifdef WIN32 # include /*#include */ #else # include # include #endif #include #define TCP_NODELAY 1 /* Macro to: 1: Check if the constant is defined. If not, omit. 2: Generate a case statement for the constant, which creates a string error description constructed from the constant name and the supplied error message. */ #define CASE_ERR(ERRNO, DESCR) #ifdef ERRNO case ERRNO strncpy( status_str, ERRNO ":" DESCR, status_len); break; #endif /* Convert integer status into a string error code */ void checkStatus(int status, char* status_str, int status_len) { status_len = status_len>1000?1000:status_len; switch(status) { /* Unix messages */ CASE_ERR(EBADF, "Invalid descriptor."); CASE_ERR(ENOTSOCK, "Descriptor is a file, not a socket."); CASE_ERR(ENOPROTOOPT, "The option is unknown at the level indicated."); CASE_ERR(EFAULT, "invalid pointer"); CASE_ERR(EINVAL, "optlen invalid in setsockopt"); /* Windows messages */ CASE_ERR(WSANOTINITIALISED, "A successful WSAStartup call must occur before using this function."); CASE_ERR(WSAENETDOWN, "The network subsystem has failed."); CASE_ERR(WSAEFAULT, "optval is not in a valid part of the process address space or optlen parameter is too small."); CASE_ERR(WSAEINPROGRESS, "A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function."); CASE_ERR(WSAEINVAL, "level is not valid, or the information in optval is not valid."); CASE_ERR(WSAENETRESET, "onnection has timed out when SO_KEEPALIVE is set."); CASE_ERR(WSAENOPROTOOPT, "he option is unknown or unsupported for the specified provider or socket (see SO_GROUP_PRIORITY limitations)."); CASE_ERR(WSAENOTCONN, "Connection has been reset when SO_KEEPALIVE is set."); CASE_ERR(WSAENOTSOCK, "The descriptor is not a socket."); case 0: strncpy( status_str, "SUCCESS", status_len); break; default: strncpy(status_str, strerror(status), status_len); break; } status_str[status_len-1] = 0x0; /* Just in case... */ } /* Function to de-nagle a TCP socket connection */ void R_setTCPNoDelay(int *socket, int* flag, int* status, char** status_str, int* status_len) { int off; /* ensure that we use only 0,1 values */ off = (*flag) ? 1 : 0; *status = setsockopt( *socket, IPPROTO_TCP, TCP_NODELAY, (char * )&off, sizeof ( off ) ); checkStatus(*status, status_str[0], *status_len); return; } /* function to check socket options */ /* NOT USED... void R_getsockopt(int *s, int *level, int *optname, int *optval, int *optlen, int *status, char *status_str, int *status_len) { *status = getsockopt(*s, *level, *optname, optval, optlen); checkStatus(*status, status_str, *status_len); } */ /* function to set socket options */ /* NOT USED ... void R_setsockopt(int *s, int *level, int *optname, int *optval, int *optlen, int *status, char *status_str, int *status_len) { *status = setsockopt(*s, *level, *optname, optval, *optlen); checkStatus(*status, status_str, *status_len); } */ gtools/src/Makevars.win0000644000176000001440000000002412261610202014654 0ustar ripleyusersPKG_LIBS = -lws2_32 gtools/NAMESPACE0000644000176000001440000000113212264347255013037 0ustar ripleyusersuseDynLib(gtools) export( addLast, ask, assert, binsearch, capture, checkRVersion, combinations, ddirichlet, defmacro, even, foldchange, foldchange2logratio, inv.logit, invalid, keywords, lastAdd, logit, logratio2foldchange, mixedorder, mixedsort, odd, permutations, permute, quantcut, rdirichlet, running, scat, setTCPNoDelay, smartbind, sprint, stars.pval, strmacro ) gtools/NEWS0000644000176000001440000001120612264352677012326 0ustar ripleyusersgtools 3.2.0 - 2014-01-11 ------------------------- New features: - The keywords() function now accepts a function or function name as an argument and will return the list of keywords associated with the named function. - New function stars.pval() which will generate p-value significance symbols ('***', '**', etc.) Bug fixes: - R/mixedsort.R: mixedorder() was failing to correctly handle numbers including decimals due to a faulty regular expression. Other changes: - capture() and sprint() are now defunct. gtools 3.1.1 - 2013-11-06 ------------------------- Bug fixes: - Fix problem with mixedorder/mixedsort when there is zero or one elements in the argument vector. gtools 3.1.0 - 2013-09-22 ------------------------- Major changes: - The function 'addLast()' (deprecated since gtools 3.0.0) is no longer available, and has been marked defunct. Bug fixes: - Modified 'mixedorder()' to use Use 'suppressWarnings() instead of 'options(warn=-1)'. This will avoid egregious warning messages when called from within a nested environment, such as when run from within 'knitr' gtools 3.0.0 - 2013-07-06 ------------------------- Major changes: - The function 'addLast()' has been deprecated because it directly manipulates the global environment, which is expressly prohibited by the CRAN policies. - A new function, 'lastAdd()' has been created to replace 'addLast()'. The name has been changed because the two functions require different syntax. 'addLast()' was used like this: byeWorld <- function() cat("\nGoodbye World!\n") addLast(byeWorld) The new 'lastAdd()' function is used like this: byeWorld <- function() cat("\nGoodbye World!\n") .Last <- lastAdd(byeWorld) Bug fixes: - Update checkRVersion() to work with R version 3.0.0 and later. Other changes: - Remove cross-reference to (obsolete?) moc package - The function 'assert()' (deprecated since gtools 2.5.0) is no longer available and has been marked defunct. gtools 2.7.1 - 2013-03-17 ------------------------- Bug fixes: - smartbind() was not properly handling factor columns when the first data frame did not include the relevant column. gtools 2.7.0 - 2012-06-19 ------------------------- New features: - smartbind() has a new 'sep' argument to allow specification of the character(s) used to separate components of constructed column names - smartbind() has a new 'verbose' argument to provide details on how coluumns are being processed Bug fixes: - smartbind() has been enhanced to improve handling of factor and ordered factor columns. gtools 2.6.2 - 2011-09-28 ------------------------- New features: - Add 'fill' argument to smartbind() to specify a value to use for missing entries. gtools 2.6.1 ------------ New features: - Add newVersionAvailable() function to compare running and latest available R versions. - Add keywords() function to show $RHOME/doc/KEYWORDS file Bug fixes: - Correct windows make flags as suggested by Brian Ripley. - Update Greg's email address and fix Rd syntax errors gtools 2.5.0 ------------ New features: - Add checkRVersion() function to determin if a newer version of R is available. - Deprecated assert() in favor of base::stopifnot Bug fixes: - Fix bug in binsearch() identified by 2.6.0 R CMD CHECK Other changes: - Improve text explanation of how defmacro() and strmacro() differ from function(). - Update definitions of odd() and even() to use modulus operator instead of division. gtools 2.4.0 ------------ - Add binsearch() function, previously in the genetics() package. gtools 2.3.1 ------------ - Add ask() function to prompt the user and collect a single response. gtools 2.3.0 ------------ - Update email address for Greg - Add new 'smartbind' function, which combines data frames efficiently, even if they have different column names. gtools 2.2.3 ------------ - setTCPNoDelay now compiles & works properly on Windows gtools 2.2.2 ------------ - src/setTCPNoDelay.c: Add C source code for setTCPNoDelay. - NAMESPACE: Add UseDynLib to NAMESPACE so the shared library gets properly loaded. - Updated Greg's email address. gtools 2.2.1 ------------ - New function 'addLast' that adds functions to R's .Last() so that they will be executed when R is terminating. - New function setTCPNoDelay() that allows the TCP_NODELAY flag to be changed on socket objects. gtools 2.1.0 ------------ - Added assert.R (and documentation) - Added the defmacro() function, extracted from Lumley T. "Programmer's Niche: Macros in {R}", R News, 2001, Vol 1, No. 3, pp 11--13, \url{http://CRAN.R-project.org/doc/Rnews/} - Added DESCRIPTION and removed DESCRIPTION.in gtools/data/0000755000176000001440000000000012261610202012512 5ustar ripleyusersgtools/data/ELISA.rda0000755000176000001440000000663312261610202014052 0ustar ripleyusers}lUotpA"oUA~} !m*"PBBHή C%(ACA5b!("]nַ /kQ;Swcqc{k[6 $Gɺ'랬{ɺXP}8¶$P?*uCCx':4wۋ-m*K\~ɑ.Nb k[[Z[67mKn^yE}sSK{CzZl%%25H.]]'yW9[>IUUKhEw$*:ɻʹNrn/ZG;/Kn'yWyIU$uws{d҄8y]r;ɻʻNrnWJޝ~OpW!ܜ[^=,+^'>N.125Uyer7^-b%w) :wLLLLLLLLLLLLLL|'ʔ;>(*a 73xMܗuû/t~߹Kz?Fέ?^u(?Tq}nGnAw|ܳkx']OVYϮn%r?F82ԇ_.W \N {7W~ՓZm:}tP8ݠ>?\[zຳ^zkXۧ> FӸnsqs}.jԿ5sC:7_+ tLGֻNS?q;w;>v\M~k|p4 gqn|sm܃zQKuu P<3\Cܘǵ/ZkyZ@.n/輦u9zk;a= Noϸt8Y7 jFak~_p]:Ύhs:>S (lтqmLjQ}Pݴ{}nTbD}yKa\&\ƁnϞ( 8y9q73n"~D{@r@eWP!4lMnJ9ϳwOd㮤 {/3OhnB}9dUi~xKF?zt=!fŹ7>GS929n$mn23~꾶7/XPV5f4Fs;{u?ҸW^<0r+)9Wt?uد~#ν:>͓՟7rD5~Ϳ!ǟ3~?:w qV*ǦC۷O^=?~>.tOF8 )]Cڿǡh9ZOg WOgJoY\{?gu5?5.9YXwogyS Sbۯ\qi~K_|D:BJz~.'-ꧏO~yQSu\3:Өwkx-)=?#^뺕|yi}MU^OQ~7-yn~?<ݥS1㨖ks!?yNav~м<%ZϨ>j>O?l~&z7?\NOzI?>z>]OwQΧNv:}/꧶ytj>y4?'^t7Tw]?G_aROoӟwuq@̹R} Zm~q]q{* &Z״mc[[鄵-ZۊokkbjijbjeiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiF`iF`iF421idL#cȘF425idM#kYȚF45iL#g9șF4r3iL#gyțF47iM#oy{G5*ʨ TPZjiZjiZjij5AFP#j 5CPc1j 5@M&P j5@M@-ZjP @-ZjeZjeZjeZjYeZjYeZj9堖Zj9堖Zj9塖Zjy塖ZjyXB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %XB` %0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % 0X` % X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%X"`%`I`I!K+6ۋVҔ).$pgtools/R/0000755000176000001440000000000012264350271012014 5ustar ripleyusersgtools/R/logit.R0000644000176000001440000000050312261610202013241 0ustar ripleyusers# $Id: logit.R 625 2005-06-09 14:20:30Z nj7w $ logit <- function(x, min=0, max=1) { p <- (x-min)/(max-min) log(p/(1-p)) } inv.logit <- function(x, min=0, max=1) { p <- exp(x)/(1+exp(x)) p <- ifelse( is.na(p) & !is.na(x), 1, p ) # fix problems with +Inf p * (max-min) + min } gtools/R/mixedsort.R0000644000176000001440000000547312261610202014154 0ustar ripleyusers# $Id: mixedsort.R 1748 2013-11-26 14:38:58Z warnes $ mixedsort <- function(x) x[mixedorder(x)] mixedorder <- function(x) { # - Split each each character string into an vector of strings and # numbers # - Separately rank numbers and strings # - Combine orders so that strings follow numbers if(length(x)<1) return(NULL) else if(length(x)==1) return(1) if( is.numeric(x) ) return( order(x) ) delim="\\$\\@\\$" numeric <- function(x) { suppressWarnings( as.numeric(x) ) } nonnumeric <- function(x) { suppressWarnings( ifelse(is.na(as.numeric(x)), toupper(x), NA) ) } x <- as.character(x) which.nas <- which(is.na(x)) which.blanks <- which(x=="") if(length(which.blanks) >0) x[ which.blanks ] <- -Inf if(length(which.nas) >0) x[ which.nas ] <- Inf #### # - Convert each character string into an vector containing single # character and numeric values. #### # find and mark numbers in the form of +1.23e+45.67 delimited <- gsub("([+-]{0,1}[0-9]+.{0,1}[0-9]*([eE][\\+\\-]{0,1}[0-9]+.{0,1}[0-9]*){0,1})", paste(delim,"\\1",delim,sep=""), x) # separate out numbers step1 <- strsplit(delimited, delim) # remove empty elements step1 <- lapply( step1, function(x) x[x>""] ) # create numeric version of data step1.numeric <- lapply( step1, numeric ) # create non-numeric version of data step1.character <- lapply( step1, nonnumeric ) # now transpose so that 1st vector contains 1st element from each # original string maxelem <- max(sapply(step1, length)) step1.numeric.t <- lapply(1:maxelem, function(i) sapply(step1.numeric, function(x)x[i]) ) step1.character.t <- lapply(1:maxelem, function(i) sapply(step1.character, function(x)x[i]) ) # now order them rank.numeric <- sapply(step1.numeric.t,rank) rank.character <- sapply(step1.character.t, function(x) as.numeric(factor(x))) # and merge rank.numeric[!is.na(rank.character)] <- 0 # mask off string values rank.character <- t( t(rank.character) + apply(matrix(rank.numeric),2,max,na.rm=TRUE) ) rank.overall <- ifelse(is.na(rank.character),rank.numeric,rank.character) order.frame <- as.data.frame(rank.overall) if(length(which.nas) > 0) order.frame[which.nas,] <- Inf retval <- do.call("order",order.frame) return(retval) } gtools/R/binsearch.R0000644000176000001440000000663112261610202014071 0ustar ripleyusers# $Id: binsearch.R 1295 2007-08-08 13:38:18Z warnes $ binsearch <- function(fun, range, ..., target=0, lower=ceiling(min(range)),upper=floor(max(range)), maxiter=100, showiter=FALSE) { # initialize lo <- lower hi <- upper counter <- 0 val.lo <- fun(lo,...) val.hi <- fun(hi,...) # check whether function is increasing or decreasing, & set sign # appropriately. if( val.lo > val.hi ) sign <- -1 else sign <- 1 # check if value is outside specified range if(target * sign < val.lo * sign) outside.range <- TRUE else if(target * sign > val.hi * sign) outside.range <- TRUE else outside.range <- FALSE # iteratively move lo & high closer together until we run out of # iterations, or they are adjacent, or they are identical while(counter < maxiter && !outside.range ) { counter <- counter+1 if(hi-lo<=1 || loupper) break; center <- round((hi - lo)/2 + lo ,0 ) val <- fun(center, ...) if(showiter) { cat("--------------\n") cat("Iteration #", counter, "\n") cat("lo=",lo,"\n") cat("hi=",hi,"\n") cat("center=",center,"\n") cat("fun(lo)=",val.lo,"\n") cat("fun(hi)=",val.hi,"\n") cat("fun(center)=",val,"\n") } if( val==target ) { val.lo <- val.hi <- val lo <- hi <- center break; } else if( sign*val < sign*target ) { lo <- center val.lo <- val } else #( val > target ) { hi <- center val.hi <- val } if(showiter) { cat("new lo=",lo,"\n") cat("new hi=",hi,"\n") cat("--------------\n") } } # Create return value retval <- list() retval$call <- match.call() retval$numiter <- counter if( outside.range ) { if(target * sign < val.lo * sign) { warning("Reached lower boundary") retval$flag="Lower Boundary" retval$where=lo retval$value=val.lo } else #(target * sign > val.hi * sign) { warning("Reached upper boundary") retval$flag="Upper Boundary" retval$where=hi retval$value=val.hi } } else if( counter >= maxiter ) { warning("Maximum number of iterations reached") retval$flag="Maximum number of iterations reached" retval$where=c(lo,hi) retval$value=c(val.lo,val.hi) } else if( val.lo==target ) { retval$flag="Found" retval$where=lo retval$value=val.lo } else if( val.hi==target ) { retval$flag="Found" retval$where=lo retval$value=val.lo } else { retval$flag="Between Elements" retval$where=c(lo, hi) retval$value=c(val.lo, val.hi) } return(retval) } gtools/R/oddeven.R0000644000176000001440000000022012261610202013543 0ustar ripleyusers# $Id: oddeven.R 1228 2007-11-30 18:05:43Z warnes $ # detect odd/even integers odd <- function(x) x %% 2 == 1 even <- function(x) x %% 2 == 0 gtools/R/defmacro.R0000644000176000001440000000300012261610202013676 0ustar ripleyusers## Code from ## ## @Article{Rnews:Lumley:2001, ## author = {Thomas Lumley}, ## title = {Programmer's Niche: Macros in {R}}, ## journal = {R News}, ## year = 2001, ## volume = 1, ## number = 3, ## pages = {11--13}, ## month = {September}, ## url = {http://CRAN.R-project.org/doc/Rnews/} ##} defmacro <- function(..., expr) #, DOTS=FALSE) { expr <- substitute(expr) a <- substitute(list(...))[-1] ## process the argument list nn <- names(a) if (is.null(nn)) nn <- rep("", length(a)) for(i in 1:length(a)) { if (nn[i] == "") { nn[i] <- paste(a[[i]]) msg <- paste(a[[i]], "not supplied") a[[i]] <- substitute(stop(foo), list(foo = msg)) } if (nn[i] == "DOTS") { nn[i] <- "..." a[[i]] <- formals(function(...){})[[1]] } } names(a) <- nn a <- as.list(a) ## this is where the work is done ff <- eval(substitute( function() { tmp <- substitute(body) eval(tmp, parent.frame()) }, list(body = expr))) ## add the argument list formals(ff) <- a ## create a fake source attribute mm <- match.call() mm$expr <- NULL mm[[1]] <- as.name("macro") attr(ff, "source") <- c(deparse(mm), deparse(expr)) ## return the 'macro' ff } gtools/R/quantcut.R0000644000176000001440000000533012261610202013772 0ustar ripleyusers# $Id: quantcut.R 1431 2010-04-28 17:23:08Z ggrothendieck2 $ quantcut <- function(x, q=seq(0,1,by=0.25), na.rm=TRUE, ... ) { quant <- quantile(x, q, na.rm=na.rm) dups <- duplicated(quant) if(any(dups)) { flag <- x %in% unique(quant[dups]) retval <- ifelse(flag, paste("[", as.character(x), "]", sep=''), NA) uniqs <- unique(quant) # move cut points over a bit... reposition <- function(cut) { flag <- x>=cut if(sum(flag)==0) return(cut) else return(min(x[flag], na.rm=na.rm)) } newquant <- sapply(uniqs, reposition) retval[!flag] <- as.character(cut(x[!flag], breaks=newquant, include.lowest=TRUE,...)) levs <- unique(retval[order(x)]) # ensure factor levels are # properly ordered retval <- factor(retval, levels=levs) ## determine open/closed interval ends mkpairs <- function(x) # make table of lower, upper sapply(x, function(y) if(length(y)==2) y[c(2,2)] else y[2:3] ) pairs <- mkpairs(strsplit(levs, '[^0-9+\\.\\-]+')) rownames(pairs) <- c("lower.bound","upper.bound") colnames(pairs) <- levs closed.lower <- rep(F,ncol(pairs)) # default lower is open closed.upper <- rep(T,ncol(pairs)) # default upper is closed closed.lower[1] <- TRUE # lowest interval is always closed for(i in 2:ncol(pairs)) # open lower interval if above singlet if(pairs[1,i]==pairs[1,i-1] && pairs[1,i]==pairs[2,i-1]) closed.lower[i] <- FALSE for(i in 1:(ncol(pairs)-1)) # open upper inteval if below singlet if(pairs[2,i]==pairs[1,i+1] && pairs[2,i]==pairs[2,i+1]) closed.upper[i] <- FALSE levs <- ifelse(pairs[1,]==pairs[2,], pairs[1,], paste(ifelse(closed.lower,"[","("), pairs[1,], ",", pairs[2,], ifelse(closed.upper,"]",")"), sep='') ) levels(retval) <- levs } else retval <- cut( x, quant, include.lowest=TRUE, ... ) return(retval) } gtools/R/combinations.R0000644000176000001440000000556612261610202014626 0ustar ripleyusers# $Id: combinations.R 1083 2007-03-23 22:53:00Z warnes $ # ## ## From email by Brian D Ripley to r-help ## dated Tue, 14 Dec 1999 11:14:04 +0000 (GMT) in response to ## Alex Ahgarin . Original version was ## named "subsets" and was Written by Bill Venables. ## combinations <- function(n, r, v = 1:n, set = TRUE, repeats.allowed=FALSE) { if(mode(n) != "numeric" || length(n) != 1 || n < 1 || (n %% 1) != 0) stop("bad value of n") if(mode(r) != "numeric" || length(r) != 1 || r < 1 || (r %% 1) != 0) stop("bad value of r") if(!is.atomic(v) || length(v) < n) stop("v is either non-atomic or too short") if( (r > n) & repeats.allowed==FALSE) stop("r > n and repeats.allowed=FALSE") if(set) { v <- unique(sort(v)) if (length(v) < n) stop("too few different elements") } v0 <- vector(mode(v), 0) ## Inner workhorse if(repeats.allowed) sub <- function(n, r, v) { if(r == 0) v0 else if(r == 1) matrix(v, n, 1) else if(n == 1) matrix(v, 1, r) else rbind( cbind(v[1], Recall(n, r-1, v)), Recall(n-1, r, v[-1])) } else sub <- function(n, r, v) { if(r == 0) v0 else if(r == 1) matrix(v, n, 1) else if(r == n) matrix(v, 1, n) else rbind(cbind(v[1], Recall(n-1, r-1, v[-1])), Recall(n-1, r, v[-1])) } sub(n, r, v[1:n]) } ## ## Original version by Bill Venables and cited by by Matthew ## Wiener (mcw@ln.nimh.nih.gov) in an email to R-help dated ## Tue, 14 Dec 1999 09:11:32 -0500 (EST) in response to ## Alex Ahgarin ## ## permutations <- function(n, r, v = 1:n, set = TRUE, repeats.allowed=FALSE) { if(mode(n) != "numeric" || length(n) != 1 || n < 1 || (n %% 1) != 0) stop("bad value of n") if(mode(r) != "numeric" || length(r) != 1 || r < 1 || (r %% 1) != 0) stop("bad value of r") if(!is.atomic(v) || length(v) < n) stop("v is either non-atomic or too short") if( (r > n) & repeats.allowed==FALSE) stop("r > n and repeats.allowed=FALSE") if(set) { v <- unique(sort(v)) if (length(v) < n) stop("too few different elements") } v0 <- vector(mode(v), 0) ## Inner workhorse if(repeats.allowed) sub <- function(n, r, v) { if(r==1) matrix(v,n,1) else if(n==1) matrix(v,1,r) else { inner <- Recall(n, r-1, v) cbind( rep( v, rep(nrow(inner),n) ), matrix( t(inner), ncol=ncol(inner), nrow=nrow(inner) * n , byrow=TRUE ) ) } } else sub <- function(n, r, v) { if(r==1) matrix(v,n,1) else if(n==1) matrix(v,1,r) else { X <- NULL for(i in 1:n) X <- rbind( X, cbind( v[i], Recall(n-1, r - 1, v[-i]))) X } } sub(n, r, v[1:n]) } gtools/R/keywords.R0000644000176000001440000000236112264347242014014 0ustar ripleyuserskeywords <- function( topic ) { file <- file.path(R.home("doc"),"KEYWORDS") if(missing(topic)) { file.show(file) } else { ## Local copy of trim.character to avoid cyclic dependency with gdata ## trim <- function(s) { s <- sub(pattern="^[[:blank:]]+", replacement="", x=s) s <- sub(pattern="[[:blank:]]+$", replacement="", x=s) s } kw <- scan(file=file, what=character(), sep="\n", quiet=TRUE) kw <- grep("&", kw, value=TRUE) kw <- gsub("&[^&]*$","", kw) kw <- gsub("&+"," ", kw) kw <- na.omit(trim(kw)) ischar <- tryCatch(is.character(topic) && length(topic) == 1L, error = identity) if (inherits(ischar, "error")) ischar <- FALSE if (!ischar) topic <- deparse(substitute(topic)) item <- paste("^",topic,"$", sep="") topics <- function(k) help.search(keyword=k)$matches[,"topic"] matches <- lapply(kw, topics) names(matches) <- kw tmp <- unlist(lapply( matches, function(m) grep(item, m, value=TRUE) )) names(tmp) } } gtools/R/dirichlet.R0000644000176000001440000000363112261610202014077 0ustar ripleyusers# $Id: dirichlet.R 625 2005-06-09 14:20:30Z nj7w $ # Posted by Ben Bolker to R-News on Fri Dec 15 2000 # http://www.r-project.org/nocvs/mail/r-help/2000/3865.html # # Some code (originally contributed by Ian Wilson # # functions for the "Dirichlet function", the multidimensional # generalization of the beta distribution: it's the Bayesian # canonical # distribution for the parameter estimates of a # multinomial distribution. # "pdirichlet" and "qdirichlet" (distribution function and quantiles) # would be more difficult because you'd first have to decide how to # define the distribution function for a multivariate distribution # ... I'm sure this could be done but I don't know how ddirichlet<-function(x,alpha) ## probability density for the Dirichlet function, where x=vector of ## probabilities ## and (alpha-1)=vector of observed samples of each type ## ddirichlet(c(p,1-p),c(x1,x2)) == dbeta(p,x1,x2) { dirichlet1 <- function(x, alpha) { logD <- sum(lgamma(alpha)) - lgamma(sum(alpha)) s<-sum((alpha-1)*log(x)) exp(sum(s)-logD) } # make sure x is a matrix if(!is.matrix(x)) if(is.data.frame(x)) x <- as.matrix(x) else x <- t(x) if(!is.matrix(alpha)) alpha <- matrix( alpha, ncol=length(alpha), nrow=nrow(x), byrow=TRUE) if( any(dim(x) != dim(alpha)) ) stop("Mismatch between dimensions of 'x' and 'alpha'.") pd <- vector(length=nrow(x)) for(i in 1:nrow(x)) pd[i] <- dirichlet1(x[i,],alpha[i,]) # Enforce 0 <= x[i,j] <= 1, sum(x[i,]) = 1 pd[ apply( x, 1, function(z) any( z <0 | z > 1)) ] <- 0 pd[ apply( x, 1, function(z) all.equal(sum( z ),1) !=TRUE) ] <- 0 pd } rdirichlet<-function(n,alpha) ## generate n random deviates from the Dirichlet function with shape ## parameters alpha { l<-length(alpha); x<-matrix(rgamma(l*n,alpha),ncol=l,byrow=TRUE); sm<-x%*%rep(1,l); x/as.vector(sm); } gtools/R/deprecated.R0000644000176000001440000000022012261610202014217 0ustar ripleyusers## useful function, raises an error if the FLAG expression is FALSE assert <- function( FLAG ) .Defunct(new="stopifnot", package="gtools") gtools/R/lastAdd.R0000644000176000001440000000063512261610202013505 0ustar ripleyusers## ## Replaces the (defunct) addLast() function. ## lastAdd <- function( fun ) { if (!is.function(fun)) stop("fun must be a function") if(!exists(".Last", envir=.GlobalEnv)) { return(fun) } else { Last <- get(".Last", envir=.GlobalEnv) newfun <- function(...) { fun() Last() } return(newfun) } } gtools/R/invalid.R0000644000176000001440000000044212261610202013553 0ustar ripleyusers# $Id: invalid.R 625 2005-06-09 14:20:30Z nj7w $ invalid <- function(x) { if( missing(x) || is.null(x) || length(x)==0 ) return(TRUE) if(is.list(x)) return(all(sapply(x,invalid))) else if(is.vector(x)) return(all(is.na(x))) else return(FALSE) } gtools/R/smartbind.R0000644000176000001440000001326412261610202014116 0ustar ripleyusers## ## Function to do rbind of data frames quickly, even if the columns don't match ## smartbind <- function(..., fill=NA, sep=':', verbose=FALSE) { data <- list(...) if(is.null(names(data))) names(data) <- as.character(1:length(data)) data <- lapply(data, function(x) if(is.matrix(x) || is.data.frame(x)) x else data.frame(as.list(x), check.names=FALSE) ) #retval <- new.env() retval <- list() rowLens <- unlist(lapply(data, nrow)) nrows <- sum(rowLens) rowNameList <- unlist(lapply( names(data), function(x) if(rowLens[x]<=1) x else paste(x, seq(1,rowLens[x]),sep=sep)) ) colClassList <- vector(mode="list", length=length(data)) factorColumnList <- vector(mode="list", length=length(data)) factorLevelList <- vector(mode="list", length=length(data)) start <- 1 blockIndex <- 1 for(block in data) { colClassList [[blockIndex]] <- list() factorColumnList[[blockIndex]] <- character(length=0) factorLevelList [[blockIndex]] <- list() if(verbose) print(head(block)) end <- start+nrow(block)-1 for(col in colnames(block)) { classVec <- class(block[,col]) ## store class and factor level information for later use colClassList[[blockIndex]][[col]] <- classVec if("factor" %in% classVec) { factorColumnList[[blockIndex]] <- c(factorColumnList[[blockIndex]], col) factorLevelList[[blockIndex]][[col]] <- levels(block[,col]) } if( !(col %in% names(retval))) { if(verbose) cat("Start:", start, " End:", end, " Column:", col, "\n", sep="") if ("factor" %in% classVec) { newclass <- "character" } else newclass <- classVec retval[[col]] <- as.vector(rep(fill,nrows), mode=newclass) } retval[[col]][start:end] <- as.vector(block[,col], mode=class(retval[[col]])) } start <- end+1 blockIndex <- blockIndex+1 } all.equal.or.null <- function(x,y,...) { if(is.null(x) || is.null(y) ) return(TRUE) else return(all.equal(x,y,...)) } ## Handle factors, merging levels for( col in unique(unlist(factorColumnList)) ) { ## Ensure column classes match across blocks colClasses <- lapply(colClassList, function(x) x[[col]]) firstNotNull <- which(!sapply(colClasses, is.null))[1] allSameOrNull <- all(sapply(colClasses[-firstNotNull], function(x) isTRUE(all.equal.or.null(colClasses[[firstNotNull]], x)) ) ) if(allSameOrNull) { # grab the first *non-NULL* class information colClass <- colClasses[[firstNotNull]] } else { warning("Column class mismatch for '", col, "'. ", "Converting column to class 'character'.") next() } ## check if factor levels are all the same colLevels <- lapply(factorLevelList, function(x) x[[col]]) firstNotNull <- which(!sapply(colLevels, is.null))[1] allSameOrNull <- all(sapply(colLevels[-firstNotNull], function(x) isTRUE(all.equal.or.null(colLevels[[firstNotNull]], x)) ) ) if(allSameOrNull) { if("ordered" %in% colClass) retval[[col]] <- ordered(retval[[col]], levels=colLevels[[firstNotNull]] ) else retval[[col]] <- factor(retval[[col]], levels=colLevels[[firstNotNull]] ) } else { ## Check if longest set of levels is a superset of all others, ## and use that one longestIndex <- which.max( sapply(colLevels, length) ) longestLevels <- colLevels[[longestIndex]] allSubset <- sapply(colLevels[-longestIndex], function(l) all(l %in% longestLevels) ) if(allSubset) { if("ordered" %in% colClass) retval[[col]] <- ordered(retval[[col]], levels=longestLevels ) else retval[[col]] <- factor(retval[[col]], levels=longestLevels ) } else { # form superset by appending to longest level set levelSuperSet <- unique(c(longestLevels, unlist(colLevels))) retval[[col]] <- factor(retval[[col]], levels=levelSuperSet ) if(length(colClass)>1) # not just plain factor { browser() warning( "column '", col, "' of class ", paste("'", colClass, "'", collapse=":", sep="'"), " converted to class 'factor'. Check level ordering." ) } } } } attr(retval,"row.names") <- rowNameList class(retval) <- "data.frame" return(retval) } gtools/R/strmacro.R0000644000176000001440000000440512261610202013762 0ustar ripleyusers strmacro <- function(..., expr, strexpr) { if(!missing(expr)) strexpr <- deparse(substitute(expr)) a <- substitute(list(...))[-1] nn <- names(a) if (is.null(nn)) nn <- rep("", length(a)) for(i in 1:length(a)) { if (nn[i] == "") { nn[i] <- paste(a[[i]]) msg <- paste(a[[i]], "not supplied") a[[i]] <- substitute(stop(foo), list(foo = msg)) } else { a[[i]] <- a[[i]] } #if (nn[i] == "DOTS") # { # nn[i] <- "..." # a[[i]] <- formals(function(...){})[[1]] # } } names(a) <- nn a <- as.list(a) ## this is where the work is done ff <- function(...) { ## build replacement list reptab <- a # copy defaults first reptab$"..." <- NULL #reptab$DOTS <- "" args <- match.call(expand.dots=TRUE)[-1] #print(args) for(item in names(args)) ##if(item %in% names(reptab)) reptab[[item]] <- args[[item]] ##else ## { ## browser() ## oldval <- reptab[["DOTS"]] ## addval <- paste(item, "=", args[[item]]) ## if(oldval>"") ## newval <- paste(c(oldval, addval), collapse=", ") ## else ## newval <- addval ## reptab[["DOTS"]] <- newval ## } #print(reptab) ## do the replacements body <- strexpr for(i in 1:length(reptab)) { pattern <- paste("\\b", names(reptab)[i], "\\b",sep='') value <- reptab[[i]] if(missing(value)) value <- "" body <- gsub(pattern, value, body) } #print(body) fun <- parse(text=body) eval(fun, parent.frame()) } ## add the argument list formals(ff) <- a ## create a fake source attribute mm <- match.call() mm$expr <- NULL mm[[1]] <- as.name("macro") attr(ff, "source") <- c(deparse(mm), strexpr) ## return the 'macro' ff } gtools/R/running.R0000644000176000001440000000460112261610202013606 0ustar ripleyusers# $Id: running.R 1568 2012-06-19 13:56:52Z warnes $ "running" <- function(X, Y=NULL, fun=mean, width=min(length(X), 20), allow.fewer=FALSE, pad=FALSE, align=c("right", "center", "left"), simplify=TRUE, by, # added a parameter ...) { align=match.arg(align) n <- length(X) if (align=="left") { from <- 1:n to <- pmin( (1:n)+width-1, n) } else if (align=="right") { from <- pmax( (1:n)-width+1, 1) to <- 1:n } else #align=="center" { from <- pmax((2-width):n,1) to <- pmin(1:(n+width-1),n) if(!odd(width)) stop("width must be odd for center alignment") } elements <- apply(cbind(from, to), 1, function(x) seq(x[1], x[2]) ) if(is.matrix(elements)) elements <- as.data.frame(elements) # ensure its a list! names(elements) <- paste(from,to,sep=':') if(!allow.fewer) { len <- sapply(elements, length) skip <- (len < width) } else { skip <- 0 } run.elements <- elements[!skip] if(!invalid(by)) run.elements <- run.elements[seq(from=1, to=length(run.elements), by=by)] if(is.null(Y)) # univariate { funct.uni <- function(which,what,fun,...) fun(what[which],...) if(simplify) Xvar <- sapply(run.elements, funct.uni, what=X, fun=fun, ...) else Xvar <- lapply(run.elements, funct.uni, what=X, fun=fun, ...) } else # bivariate { funct.bi <- function(which,XX,YY,fun,...) fun(XX[which],YY[which], ...) if(simplify) Xvar <- sapply(run.elements, funct.bi, XX=X, YY=Y, fun=fun, ...) else Xvar <- lapply(run.elements, funct.bi, XX=X, YY=Y, fun=fun, ...) } if(allow.fewer || !pad) return(Xvar) if(simplify) if(is.matrix(Xvar)) { wholemat <- matrix( new(class(Xvar[1,1]), NA), ncol=length(to), nrow=nrow(Xvar) ) colnames(wholemat) <- paste(from,to,sep=':') wholemat[,-skip] <- Xvar Xvar <- wholemat } else { wholelist <- rep(new(class(Xvar[1]),NA),length(from)) names(wholelist) <- names(elements) wholelist[ names(Xvar) ] <- Xvar Xvar <- wholelist } return(Xvar) } gtools/R/addLast.R0000644000176000001440000000023412261610202013500 0ustar ripleyusersaddLast <- function( fun ) .Defunct(new=paste(".Last <- lastAdd(", deparse(substitute(fun)), ")", sep=''), package='gtools' ) gtools/R/newVersionAvailable.R0000644000176000001440000000144312261610202016067 0ustar ripleyusersnewVersionAvailable <- function(quiet=FALSE) { page <- scan(file="http://cran.r-project.org/src/base/R-2", what="", quiet=TRUE) matches <- grep("R-[0-9]\\.[0-9]+\\.[0-9]+", page, value=TRUE) versionList <- gsub("^.*R-([0-9].[0-9]+.[0-9]+).*$","\\1",matches) versionList <- numeric_version(versionList) if( max(versionList) > getRversion() ) { if(!quiet) { cat("A newer version of R is now available: ") cat(max(versionList)) cat("\n") } invisible( max(versionList) ) } else { if(!quiet) { cat("The latest version of R is installed: ") cat(as.character(getRversion())) cat("\n") } invisible( NULL ); } } gtools/R/setTCPNoDelay.R0000644000176000001440000000125012261610202014541 0ustar ripleyuserssetTCPNoDelay <- function( socket, value=TRUE ) { if(!any(c("socket","sockconn") %in% class(socket))) stop("socket must be a socket object") buffer <- paste(rep(" ", 1000), sep='', collapse='') conn <- getConnection(socket[1]) retval <- .C("R_setTCPNoDelay", socket=as.integer(socket[1]), flag=as.integer(value), status=integer(1), status.str=as.character(buffer), status.len=as.integer(nchar(buffer)), package="gtools" ) if(retval$status != 0) stop( retval$status.str ) else invisible(retval$status.str) } gtools/R/foldchange.R0000644000176000001440000000100712261610202014215 0ustar ripleyusers# $Id: foldchange.R 625 2005-06-09 14:20:30Z nj7w $ foldchange <- function(num,denom) { ifelse(num >= denom, num/denom, -denom/num) } # Compute foldchange from log-ratio values logratio2foldchange <- function(logratio, base=2) { retval <- base^(logratio) retval <- ifelse(retval < 1, -1/retval, retval) retval } # vice versa foldchange2logratio <- function(foldchange, base=2) { retval <- ifelse( foldchange<0, 1/-foldchange, foldchange) retval <- log(retval,base) retval } gtools/R/defunct.R0000644000176000001440000000023212264350420013560 0ustar ripleyuserscapture <- function( expression, collapse="\n") .Defunct("capture.output", "base") sprint <- function(x,...) .Defunct("capture.output", "base") gtools/R/RSCompat.S0000644000176000001440000001227312261610202013623 0ustar ripleyusers# $Id: RSCompat.S 625 2005-06-09 14:20:30Z nj7w $ # # $Log$ # Revision 1.9 2005/06/09 14:20:28 nj7w # Updating the version number, and various help files to synchronize splitting of gregmisc bundle in 4 individual components. # # Revision 1.1.1.1 2005/05/25 22:17:28 nj7w # Initial submision as individual package # # Revision 1.8 2003/04/04 13:58:59 warnes # # - Replace 'T' with 'TRUE' # # Revision 1.7 2003/03/07 15:48:35 warnes # # - Minor changes to code to allow the package to be provided as an # S-Plus chapter. # # Revision 1.6 2003/01/02 15:42:00 warnes # - Add nlevels function. # # Revision 1.5 2002/03/20 03:44:32 warneg # - Added definition of is.R function. # # - Added boxplot.formula # # Revision 1.4 2002/02/05 02:20:07 warneg # # - Fix typo that caused code meant to run only under S-Plus to run # under R, causing problems. # # Revision 1.3 2001/12/19 22:45:44 warneg # - Added code for %in%. # # Revision 1.2 2001/09/18 14:15:44 warneg # # Release 0.3.2 # # Revision 1.1 2001/09/01 19:19:13 warneg # # Initial checkin. # # # Code necessary for contrast.lm, boxplot.n to work in S-Plus if(!exists("is.R") || !is.R() ) { is.R <- function() FALSE getOption <- function(...) options(...) if(!exists("parent.frame")) parent.frame <- sys.parent colnames <- function (x, do.NULL = TRUE, prefix = "col") { dn <- dimnames(x) if (!is.null(dn[[2]])) dn[[2]] else { if (do.NULL) NULL else paste(prefix, seq(length = NCOL(x)), sep = "") } } rownames <- function (x, do.NULL = TRUE, prefix = "row") { dn <- dimnames(x) if (!is.null(dn[[1]])) dn[[1]] else { if (do.NULL) NULL else paste(prefix, seq(length = NROW(x)), sep = "") } } "rownames<-" <- function (x, value) { dn <- dimnames(x) ndn <- names(dn) dn <- list(value, if (!is.null(dn)) dn[[2]]) names(dn) <- ndn dimnames(x) <- dn x } "colnames<-" <- function (x, value) { dn <- dimnames(x) ndn <- names(dn) dn <- list(if (!is.null(dn)) dn[[1]], value) names(dn) <- ndn dimnames(x) <- dn x } # from the MASS library by Venables & Ripley ginv <- function (X, tol = sqrt(.Machine$double.eps)) { if (length(dim(X)) > 2 || !(is.numeric(X) || is.complex(X))) stop("X must be a numeric or complex matrix") if (!is.matrix(X)) X <- as.matrix(X) Xsvd <- svd(X) if (is.complex(X)) Xsvd$u <- Conj(Xsvd$u) Positive <- Xsvd$d > max(tol * Xsvd$d[1], 0) if (all(Positive)) Xsvd$v %*% (1/Xsvd$d * t(Xsvd$u)) else if (!any(Positive)) array(0, dim(X)[2:1]) else Xsvd$v[, Positive] %*% ((1/Xsvd$d[Positive]) * t(Xsvd$u[, Positive])) } "format.pval" <- function (pv, digits = max(1, getOption("digits") - 2), eps = .Machine$double.eps, na.form = "NA") { if ((has.na <- any(ina <- is.na(pv)))) pv <- pv[!ina] r <- character(length(is0 <- pv < eps)) if (any(!is0)) { rr <- pv <- pv[!is0] expo <- floor(log10(pv)) fixp <- expo >= -3 | (expo == -4 & digits > 1) if (any(fixp)) rr[fixp] <- format(pv[fixp], dig = digits) if (any(!fixp)) rr[!fixp] <- format(pv[!fixp], dig = digits) r[!is0] <- rr } if (any(is0)) { digits <- max(1, digits - 2) if (any(!is0)) { nc <- max(nchar(rr)) if (digits > 1 && digits + 6 > nc) digits <- max(1, nc - 7) sep <- if (digits == 1 && nc <= 6) "" else " " } else sep <- if (digits == 1) "" else " " r[is0] <- paste("<", format(eps, digits = digits), sep = sep) } if (has.na) { rok <- r r <- character(length(ina)) r[!ina] <- rok r[ina] <- na.form } r } "%in%" <- function (x, table) match(x, table, nomatch = 0) > 0 strwidth <- function(...) { par("cin")[1] / par("fin")[1] * (par("usr")[2] - par("usr")[1]) } strheight <- function(...) { par("cin")[2] / par("fin")[2] * (par("usr")[4] - par("usr")[3]) } boxplot.formula <- function(x, data = sys.parent(), ..., ask = TRUE) { if(!inherits(x, "formula")) x <- as.formula(x) mf <- model.frame(x, data, na.action = function(z) z) if(length(names(mf)) > 2) stop("boxplot.formula only accepts models with 1 predictor") resp <- attr(attr(mf, "terms"), "response") class(mf) <- NULL y <- mf[[resp]] x <- mf[[-resp]] xlab <- names(mf)[-resp] ylab <- names(mf)[resp] boxplot(split(y, x), xlab = xlab, ylab = ylab, ...) } nlevels <- function(x) length(levels(x)) NULL } gtools/R/ask.R0000644000176000001440000000020112261610202012674 0ustar ripleyusersask <- function(msg="Press to continue: ") { cat(msg); readLines(con=stdin(),n=1) } gtools/R/stars.pval.R0000644000176000001440000000040512261610202014221 0ustar ripleyusersstars.pval <- function(p.value) { unclass( symnum(p.value, corr = FALSE, na = FALSE, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c("***", "**", "*", ".", " ")) ) } gtools/R/permute.R0000644000176000001440000000016412261610202013607 0ustar ripleyusers# $Id: permute.R 625 2005-06-09 14:20:30Z nj7w $ permute <- function(x) sample( x, size=length(x), replace=FALSE ) gtools/R/scat.R0000644000176000001440000000052612261610202013062 0ustar ripleyusers# $Id: scat.R 625 2005-06-09 14:20:30Z nj7w $ # cat to stdout and immediately flush scat <- function(...) { DEBUG <- options()$DEBUG if( !is.null(DEBUG) && DEBUG) { cat("### ", file=stderr()) cat(..., file=stderr()) cat(" ###\n", file=stderr()) flush(stderr()) } invisible(NULL) } gtools/R/checkRVersion.R0000644000176000001440000000172312261610202014675 0ustar ripleyuserscheckRVersion <- function(quiet=FALSE) { page2 <- scan(file="http://cran.r-project.org/src/base/R-2", what="", quiet=TRUE) page3 <- scan(file="http://cran.r-project.org/src/base/R-3", what="", quiet=TRUE) combined <- c(page2, page3) matches <- grep("R-[0-9]\\.[0-9]+\\.[0-9]+", combined, value=TRUE) versionList <- gsub("^.*R-([0-9].[0-9]+.[0-9]+).*$","\\1",matches) versionList <- numeric_version(versionList) if( max(versionList) > getRversion() ) { if(!quiet) { cat("A newer version of R is now available: ") cat(as.character(max(versionList))) cat("\n") } invisible( max(versionList) ) } else { if(!quiet) { cat("The latest version of R is installed: ") cat(as.character(max(versionList))) cat("\n") } invisible( NULL ); } } gtools/MD50000644000176000001440000000541112265000227012116 0ustar ripleyusers16db02154eca1ae541425bd399892fc2 *ChangeLog 3fad5dcef199283106bf5a1ab30bf975 *DESCRIPTION 6e384f31ff7ed1bb05c7ca706be9d618 *NAMESPACE aa2e103a8b06d2fbf51715951914dd8b *NEWS 9eb418fd95aa09ba85aed159545dea61 *R/RSCompat.S a86a74ba04089ad58ea22e3a994a9b14 *R/addLast.R c4ae0d6b5867f6751981e9f93cd2f619 *R/ask.R d2308a673e3f0e0ee3aac816fed729a9 *R/binsearch.R c70220a92fd3c5781638e3779cbd55ff *R/checkRVersion.R 529f69b81b6b734a4f637d250b5b71f9 *R/combinations.R 1c333b16a59dcaf7ccf20151962b6375 *R/defmacro.R 28d70252e7e25f8e3743fc07434acba9 *R/defunct.R 344b58e1976792a3295238c17df7e917 *R/deprecated.R c089bb5f542501dc1e3ba07f032c84ed *R/dirichlet.R 1da2198e1d194c705ca89381159b7b63 *R/foldchange.R 71212f4c14003458fc3e30638f339629 *R/invalid.R 11fc8cb8e4bd7c93cd8edefe54b9c64c *R/keywords.R f00dfc3263a5854151f244493b3f04d0 *R/lastAdd.R 2bb525e1930ec3ba2afefa2ff43d74e0 *R/logit.R a1335136622137e3a287f2fd7b39b4f9 *R/mixedsort.R 93a46a6ef5937bdd112468daceac00a6 *R/newVersionAvailable.R 07cd779ab7e64f697604b8b4fa4c9d70 *R/oddeven.R 1d016a924dd59daa78ea62d986da2929 *R/permute.R 576dc3d2738e3eeedbce8e9f5d5765a1 *R/quantcut.R 02390191f23321a34fcfc41719d66dc6 *R/running.R a5ea32bab219fd7c634f034dddada96b *R/scat.R e5ddc84d8a502feed32f7f6b1b5e25ab *R/setTCPNoDelay.R 3d0ac64f38d5b91d4ef8adc2344d5875 *R/smartbind.R ef22fb4007dec9fb62eb5ed947292fa3 *R/stars.pval.R e8f510e73bd2cd820c384c00d75b0080 *R/strmacro.R d2d2d0444a049d74694203974624835c *data/ELISA.rda 16db02154eca1ae541425bd399892fc2 *inst/ChangeLog aa2e103a8b06d2fbf51715951914dd8b *inst/NEWS 904304f52b08ec847904ac2aa5be9aef *man/ELISA.Rd c5b7124f5fdbcc83f2e283314df95858 *man/ask.Rd ecbe8481bdcff0d8abd1a47cc64ca7b2 *man/binsearch.Rd e1a3f01f01db3e883397eaa49037af6f *man/checkRVersion.Rd 0b2fba4b1456254689640add6afec843 *man/combinations.Rd 1c240ef01582dd99e3a2e432e7dfb2ba *man/defmacro.Rd 22b71a514ea7acc360552527394ce9c1 *man/dirichlet.Rd 74868a3948263db0fbc2519b792acba2 *man/foldchange.Rd aa98190531ff93721b715e61000f76a4 *man/gtools-defunct.Rd 72d1da64e38796cc37347aa1be02bdd2 *man/gtools-deprecated.Rd 01c743eee2dbb9dc14d02035fa05063c *man/invalid.Rd 8d8b5429047edd4ed52f8f8f6b11f807 *man/keywords.Rd 67b9c146bd8470b1dd5ddcac782c2071 *man/lastAdd.Rd 3c207d731ad8ead62af138afe2e20c5f *man/logit.Rd 422c16f570c15590fa83e1a71506757f *man/mixedsort.Rd f4d6f8222b9448ef039d9cbf582ee29e *man/oddeven.Rd f911c6c34412df66c1ff0d6376f46c3f *man/permute.Rd 30ac79ee93340f4174ddf91022154c0c *man/quantcut.Rd 20033253beddc01faf5829cdf43f01fb *man/running.Rd f781e22f646cf803a7f24129525521fc *man/scat.Rd 5dae46a9758c2a81d25d87881f7b42ee *man/setTCPNoDelay.Rd 6661dfc3dcf520520106b3d74a893259 *man/smartbind.Rd 7ba286fa2b1bc994de1c6ec78883cdc8 *man/stars.pval.Rd 8d4158b8eb92153e2d3f581682b2a3c1 *src/Makevars.win bb28a3858ac5a6152565d3b8cef8c70c *src/setTCPNoDelay.c gtools/DESCRIPTION0000644000176000001440000000055612265000227013321 0ustar ripleyusersPackage: gtools Title: Various R programming tools Description: Various R programming tools Version: 3.2.1 Date: 2014-01-13 Author: Gregory R. Warnes, Ben Bolker, and Thomas Lumley Maintainer: Gregory R. Warnes License: LGPL-2.1 Packaged: 2014-01-13 14:07:20 UTC; warnes NeedsCompilation: yes Repository: CRAN Date/Publication: 2014-01-13 16:04:55 gtools/ChangeLog0000644000176000001440000005620312264352252013374 0ustar ripleyusers2014-01-11 warnes * [r1762] DESCRIPTION, NAMESPACE, R/capture.R, R/defunct.R, R/keywords.R, man/capture.Rd, man/gtools-defunct.Rd, man/stars.pval.Rd: Fixes for gtools release 3.2.0 2013-12-23 warnes * [r1761] R/keywords.R, man/keywords.Rd: Extend the keywords() function to return keywords associated with a specified topic via 'keywords(topic)'. * [r1760] man/stars.pval.Rd: Add keyword. * [r1759] NAMESPACE, R/stars.pval.R, man/stars.pval.Rd: Add stars.pval() function to convert p-values into significance symbols. 2013-11-26 warnes * [r1748] R/mixedsort.R: mixedorder() was failing to correctly handle numbers including decimals due to a faulty regular expression. Prior to the fix: > drr [1] "Dose 0.3 mg" "Dose 0.04 mg" "Dose 0.5 mg" > gtools::mixedsort(drr) [1] "Dose 0.3 mg" "Dose 0.04 mg" "Dose 0.5 mg" After the fix: > drr [1] "Dose 0.3 mg" "Dose 0.04 mg" "Dose 0.5 mg" > mixedsort(drr) [1] "Dose 0.04 mg" "Dose 0.3 mg" "Dose 0.5 mg" In addition, an optimization was added that checked if the input vector was numeric. If so, simply use the existing base::order function. 2013-11-18 warnes * [r1747] R/capture.R: Use ".Deprecated" instead of warning. 2013-11-06 warnes * [r1746] DESCRIPTION, inst/NEWS: Update files for gtools 3.1.1 * [r1745] R/mixedsort.R: Fix problem with mixedorder/mixedsort when there is only zero or one elements in the vector. 2013-09-23 warnes * [r1716] man/gtools-deprecated.Rd: Comment out empty sections in gtools-deprecated.Rd * [r1715] DESCRIPTION, inst/NEWS: Update files for gtools 3.1.0 release * [r1714] man/addLast-deprecated.Rd, man/gtools-defunct.Rd, man/gtools-deprecated.Rd, man/lastAdd.Rd: Make 'addLast()' defunct. * [r1713] R/addLast.R, R/lastAdd.R: Mark 'addLast()' as defunct and move 'lastAdd()' function to a separate file. * [r1712] DESCRIPTION, inst/NEWS: Update for gtools 3.0.1 release * [r1711] R/mixedsort.R: Use 'suppressWarnings() instead of 'options(warn=-1)' in 'mixedorder()'. 2013-07-07 warnes * [r1705] man/lastAdd.Rd: Fix typo. 2013-07-06 warnes * [r1704] man/lastAdd.Rd: Fix Rd warning. * [r1703] NAMESPACE: Include lastAdd in NAMESPACE * [r1702] R/deprecated.R: Change assert from deprecated to defunct. * [r1701] R/addLast.R: Improve deprecation message * [r1700] DESCRIPTION, inst/NEWS: Update for gtools 3.0.0 * [r1699] R/addLast.R, man/addLast-deprecated.Rd, man/addLast.Rd, man/gtools-defunct.Rd, man/gtools-deprecated.Rd, man/lastAdd.Rd: Create new function lastAdd to replace addLast and mark addLast as deprecated. 2013-07-05 warnes * [r1698] inst/NEWS: Point out that addLast() modifies the value of .Last in the global environment. * [r1697] man/addLast.Rd: Point out that addLast() modifies the value of .Last in the global environment. * [r1696] DESCRIPTION, inst/NEWS: Update for gtools 2.7.2 mark 2 * [r1695] man/logit.Rd: Remove cross-reference to (obsolete?) moc package * [r1694] DESCRIPTION, inst/NEWS: Update for gtools 2.7.2 * [r1693] R/checkRVersion.R: Update for R version 3.0.0 and later 2013-03-17 warnes * [r1640] R/smartbind.R: Fix error in smartbind: factor levels were not being handled if the factor column was not present in the first data frame. 2012-06-19 warnes * [r1570] DESCRIPTION, inst/NEWS: Update for gtools 2.7.0. * [r1569] man/smartbind.Rd: Document new 'verbose' argument to smartbind(). * [r1568] R/addLast.R, R/running.R: Clean up R CMD check warnings. 2012-05-04 warnes * [r1529] R/smartbind.R: smartbind(): Improve handling of factors and ordered factors. 2011-10-05 warnes * [r1518] DESCRIPTION: Update version number for release * [r1517] R/smartbind.R, man/smartbind.Rd: Add 'sep' argument to smartbind() to allow specification of character used to separate components of constructed names 2011-09-28 warnes * [r1513] R/smartbind.R: smartbind(): Prevent coersion to data frame from mangling column names. * [r1512] R/smartbind.R, inst/NEWS: Add 'fill' argument to smartbind() to specify a value to use for missing entries. * [r1511] DESCRIPTION, man/smartbind.Rd: Add 'fill' argument to smartbind() to specify a value to use for missing entries. 2010-08-14 warnes * [r1451] R/mixedsort.R: Modify mixedorder()/mixedsort() to better handle strings containing multiple periods, like version numbers (e.g 1.1.2, 1.2.1. 1.1.1.1). 2010-05-01 warnes * [r1434] DESCRIPTION: Update version number for new release * [r1433] DESCRIPTION, man/addLast.Rd, man/ask.Rd, man/binsearch.Rd, man/capture.Rd, man/combinations.Rd, man/defmacro.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/invalid.Rd, man/keywords.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd, man/setTCPNoDelay.Rd, man/smartbind.Rd: Change Greg's email address to greg@warnes.net * [r1432] R/checkRVersion.R: Fix error in checkRVersion() 2010-04-28 ggrothendieck2 * [r1431] R/quantcut.R, R/strmacro.R, man/binsearch.Rd, man/capture.Rd, man/setTCPNoDelay.Rd: fixed problems with R CMD CHECK 2009-05-09 warnes * [r1328] man/keywords.Rd: Escape $ in .Rd file to avoid latex issues * [r1327] ChangeLog, NEWS, inst/NEWS: Update NEWS and create softlinks for NEWS and ChangeLog in top level directory * [r1326] NEWS, inst, inst/NEWS: Move actual NEWS file into inst. * [r1325] DESCRIPTION, man/addLast.Rd, man/binsearch.Rd, man/capture.Rd, man/combinations.Rd, man/defmacro.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/gtools-deprecated.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd, man/setTCPNoDelay.Rd, man/smartbind.Rd: Update Greg's email address and fix Rd syntax errors 2009-02-16 warnes * [r1313] src/Makevars.win: Correct windows make flags as suggested by Brian Ripley. 2008-08-15 warnes * [r1303] DESCRIPTION, NAMESPACE, R/keywords.R, man/keywords.Rd: Add keywords() function to show /doc/KEYWORDS file 2008-05-29 warnes * [r1285] R/newVersionAvailable.R: Add newVersionAvailable() function to compare running and latest available R versions 2008-05-26 warnes * [r1284] DESCRIPTION: Update license specification * [r1283] man/assert-deprecated.Rd: Remove 'assert' man page 2008-05-22 warnes * [r1282] man/assert.R: Finish rename of assert.R to assert-depricated.Rd * [r1281] R/checkRVersion.R: Add checkRVersion.R file * [r1280] man/assert-deprecated.Rd: Rename again to get correct extension! * [r1279] NEWS: Update NEWS for 2.5.0 * [r1278] man/checkRVersion.Rd: Add man page for checkRVersion * [r1277] man/assert-deprecated.R, man/assert.R: Rename assert-deprecated.R to assert.R to meet R file name requirements. * [r1276] DESCRIPTION, NAMESPACE: Add checkRVersion to NAMESPACE, and increment version in DESCRIPTION. * [r1275] man/gtools-deprecated.Rd: Remove broken SEE LSO reference 2008-04-12 warnes * [r1259] man/defmacro.Rd: Improve text explanation of how defmacro() and strmacro() differ from function(). * [r1258] NEWS, man/assert-deprecated.R, man/assert.Rd, man/gtools-deprecated.Rd: assert() is now deprecated in favor of base::stopifnot() * [r1257] R/assert.R, R/deprecated.R: Rename 'assert.R' to 'deprecated.R'. * [r1256] R/assert.R: Assert is now deprecated in favor of base::stopifnot(), so add call to .Deprecated() to inform the user. 2007-11-30 warnes * [r1228] R/oddeven.R: Update defnitions of odd() and even() to use modulus operator instead of division. Prettier, I think, :-D 2007-08-08 warnes * [r1121] DESCRIPTION, R/binsearch.R: Fix bug identified by R-2.6's check routings in binsearch() * [r1120] DESCRIPTION, NAMESPACE, NEWS, R/binsearch.R, man/binsearch.Rd: Add the binsearch(), previously in the genetics package. 2007-07-18 ggorjan * [r1100] man/combinations.Rd: typo fixed 2007-04-12 warnes * [r1088] NAMESPACE, NEWS, R/ask.R, man/ask.Rd: Add ask() function to prompt the user and collect a single response. 2007-04-07 warnes * [r1087] DESCRIPTION, R/mixedsort.R: Fix improper escapes in regexp detected by R 2.5.0 package check. 2007-03-23 warnes * [r1083] R/combinations.R: Allow permutations for r>n provided repeats.allowed=TRUE 2006-11-28 warnes * [r1023] man/smartbind.Rd: Replace F with FALSE in smartbind example. 2006-11-27 warnes * [r1022] man/smartbind.Rd: Replace T with TRUE in smartbind example * [r1021] data/ELISA.rda: Temprary remove to reset binary flag * [r1020] data/ELISA.rda: Temprary remove to reset binary flag * [r1019] DESCRIPTION, NAMESPACE, NEWS, R/smartbind.R, man/smartbind.Rd: Add smartbind() to list of exported functions, and add corresponding documentation file. * [r1018] DESCRIPTION: Update my email address 2006-11-14 ggorjan * [r1012] R/combinations.R, R/running.R, man/ELISA.Rd, man/combinations.Rd: Removed executable property 2006-08-02 warnes * [r977] man/addLast.Rd, man/assert.Rd, man/capture.Rd, man/combinations.Rd, man/defmacro.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd, man/setTCPNoDelay.Rd: Update my email address 2006-05-05 nj7w * [r958] man/combinations.Rd: Fixed minor typo - in {value} - n was replaced by r * [r957] NAMESPACE, man/capture.Rd: Fixed minor typos 2006-03-01 warnes * [r903] R/smartbind.R: Add smartbind function 2006-01-18 warnes * [r845] man/mixedsort.Rd: Add concept tags to make mixedsort easier to locate. 2005-12-21 warnes * [r837] DESCRIPTION: Update version number and date * [r836] NEWS: Note changes for 2.2.3 * [r835] src/Makevars.win, src/setTCPNoDelay.c: Should now work on Windows 2005-12-20 warnes * [r834] src/setTCPNoDelay.c: Temporary fix to allow setTCPNoDelay.c to compile on Windows. If compiled on windows calling setTCPNoDelay will just raise an error. 2005-12-14 warnes * [r813] src/setTCPNoDelay.c: Change C++ comment to standard comment 2005-12-13 nj7w * [r810] ChangeLog: *** empty log message *** * [r809] NEWS: Updated NEWS and removed ChangeLog 2005-12-12 nj7w * [r800] DESCRIPTION: Updated version for CRAN release 2005-12-08 warnes * [r790] src, src/setTCPNoDelay.c: Add C source code for setTCPNoDelay. 2005-12-01 nj7w * [r776] man/combinations.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/quantcut.Rd, man/running.Rd: Updated Greg's email address 2005-11-29 warnes * [r769] NAMESPACE: Add UseDynLib to NAMESPACE so the shared library gets properly loaded. * [r768] R/setTCPNoDelay.R: - Remove debugging comments - Change return value on success to "Success". 2005-11-22 warnes * [r758] NAMESPACE: NAMESPACE * [r757] NEWS: Update news for 2.2.1 release. * [r756] man/addLast.Rd, man/setTCPNoDelay.Rd: Fixes for R CMD check * [r755] DESCRIPTION, NAMESPACE, R/setTCPNoDelay.R, man/setTCPNoDelay.Rd: Add setTCPNoDelay() function and documentation * [r745] R/addLast.R, man/addLast.Rd: New function 'addLast' that adds functions to R's .Last() so that they will be executed when R is terminating. 2005-09-22 warnes * [r678] DESCRIPTION, NAMESPACE, man/defmacro.Rd: More changes for strmacro(), also changes for 2.1.1 release * [r677] R/defmacro.R, R/strmacro.R, man/defmacro.Rd: Add strmaco() which defines functions that use strings for macro definition 2005-09-21 warnes * [r676] DESCRIPTION, R/defmacro.R, man/defmacro.Rd: Add support for DOTS/... arguments to defmacro 2005-09-12 nj7w * [r671] man/assert.Rd, man/dirichlet.Rd, man/permute.Rd, man/scat.Rd: Updated Greg's email 2005-09-02 nj7w * [r653] NAMESPACE: Exported assert * [r652] DESCRIPTION: Updated the version number * [r651] NEWS: Added NEWS * [r650] ChangeLog: Added ChangeLog * [r649] man/assert.Rd: Fixed syntax errors 2005-09-02 warnes * [r648] R/assert.R, man/assert.Rd: Add assert() and documentation * [r647] man/defmacro.Rd: Fix problem in defmacro.Rd file: don't use \code{} in the example section. 2005-08-31 warnes * [r645] DESCRIPTION, NAMESPACE, R/defmacro.R, man/defmacro.Rd: Adding the defmacro() function, extracted from Lumley T. "Programmer's Niche: Macros in {R}", R News, 2001, Vol 1, No. 3, pp 11--13, \url{http://CRAN.R-project.org/doc/Rnews/} * [r642] DESCRIPTION, DESCRIPTION.in: Add stand-alone DESCRIPTION file and remove old DESCRIPTION.in file. 2005-06-13 nj7w * [r626] R/mixedsort.R: Fixed a bug in mixedsort - check if "which.na" and "which.blank" is numeric(0) before subsetting the datasets. 2005-06-09 nj7w * [r625] R/RSCompat.S, R/combinations.R, R/dirichlet.R, R/foldchange.R, R/invalid.R, R/logit.R, R/mixedsort.R, R/oddeven.R, R/permute.R, R/quantcut.R, R/running.R, R/scat.R, man/ELISA.Rd, man/combinations.Rd, man/dirichlet.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd, man/scat.Rd: Updating the version number, and various help files to synchronize splitting of gregmisc bundle in 4 individual components. 2005-05-10 warnes * [r619] R/mixedsort.R: Fix handling of NA's in mixedorder. We were using a high UTF character to try to put NA's at the end of the sort order, but R 2.1.0 checks if characters are in the correct range. Instead, we explicitly force NA's to the end. 2005-04-07 warnes * [r606] NAMESPACE, R/scat.R, man/scat.Rd: - Add scat() function which writes its arguments to stderr and flushes so that output is immediately displayed, but only if 'getOption("DEBUG")' is true. 2005-04-02 warnes * [r600] NAMESPACE, R/drop.levels.R, man/drop.levels.Rd: Move drop.levels() from gtools to gdata. * [r599] R/mixedsort.R: Minor reordering of functions in file * [r598] NAMESPACE, R/frameApply.R, man/frameApply.Rd: Move frameApply() to gdata package. * [r597] R/mixedsort.R: Fix error if only one value passed to mixedorder. * [r596] R/quantcut.R, man/quantcut.Rd: Add proper handling where more than one quantile obtains the same value 2005-04-01 warnes * [r595] man/ELISA.Rd, man/combinations.Rd, man/dirichlet.Rd, man/drop.levels.Rd, man/foldchange.Rd, man/invalid.Rd, man/logit.Rd, man/mixedsort.Rd, man/oddeven.Rd, man/permute.Rd, man/quantcut.Rd, man/running.Rd: Add CVS ID tag to file headers. * [r594] R/frameApply.R, man/frameApply.Rd: Fixes from Jim Rogers for R CMD check problems in frameApply 2005-03-31 warnes * [r591] R/drop.levels.R, R/frameApply.R, man/drop.levels.Rd, man/frameApply.Rd: Updates to drop.levels() and frameApply() from Jim Rogers * [r590] data, data/ELISA.rda, man/ELISA.Rd: Add ELISA data set used by frameApply and drop.levels examples 2005-02-25 warnes * [r562] man/frameApply.Rd: Replace 'T' with TRUE. * [r561] man/frameApply.Rd: Remove dependency on ELISA data set for the example. * [r558] NAMESPACE: Add drop.levels, frameApply to namespace export. 2005-02-15 warnes * [r542] R/drop.levels.R, R/frameApply.R, man/drop.levels.Rd, man/frameApply.Rd: Add frameApply and drop.levels contributed by Jim Rogers. 2005-01-12 warnes * [r515] DESCRIPTION.in: Add dependency on R 1.9.0+ to prevent poeple from installing on old versions of R which don't support namespaces. 2004-09-27 warneg * [r461] DESCRIPTION, DESCRIPTION.in, man/running.Rd: Updated to pass R CMD check. 2004-09-03 warneg * [r446] DESCRIPTION, NAMESPACE, R/dirichlet.R, R/foldchange.R, R/invalid.R, R/mixedsort.R, R/oddeven.R, R/permute.R, R/quantcut.R, R/running.R, man/running.Rd: initial bundle checkin 2004-09-02 warneg * [r442] DESCRIPTION, DESCRIPTION.in, NAMESPACE: Initial revision 2004-08-27 warnes * [r441] R/mixedsort.R, man/mixedsort.Rd: Fixed bug in mixedsort, and modified reorder.factor to use mixedsort. 2004-08-26 warnes * [r440] R/mixedsort.R: - Fix bug pointed out by Jim Rogers. - Use a more distictive internal separator: $@$ instead of just $ - Capitalization is now irrelevent for search order (unlike ASCII). 2004-06-08 warnes * [r372] R/running.R, man/running.Rd: Nitin Jain added by= parameter to allow specifying separation between groups. 2004-05-26 warnes * [r345] man/combinations.Rd: Escape underscores in email addresses so Latex is happy. * [r343] R/combinations.R: Replace 'T' with 'TRUE' to pass R CMD check. 2004-05-25 warnes * [r334] R/combinations.R: Remove extraneous comments. * [r333] R/combinations.R: Fix an error in the code when using repeats.allow=T and r>2. Bug report and fix both due to Elizabeth Purdom . 2004-05-24 warnes * [r323] R/invalid.R: Check if argument is a vector before doing is.na to avoid generating a warning. * [r322] R/invalid.R, man/invalid.Rd: Add invalid() function for testing if a parameter value is non-missing, non-NA, non-NULL. 2004-04-27 warnes * [r321] R/running.R, man/running.Rd: Replaced argument `as.list' with `simplify'. Updated documentation, and updated examples appropriately. 2004-04-26 warnes * [r320] R/running.R, man/running.Rd: Added as.list argument to return one list element per evaluation. 2004-03-26 warnes * [r303] man/combinations.Rd: Uncomment and fix large 'n' example. * [r301] man/running.Rd: - Update to match changes in running() - Add examples to illustrate new arguments. - Modify running correlation plot example to be more clear. * [r299] R/running.R: More of the same. * [r297] R/running.R: Fix bug discovered by Sean Davis . The running function took an improper shortcut. When allow.fewer=FALSE it was still passing shorter lists of elements to the called function, and then overwriting the results for the shorter lists with NAs. The code now skips evaluation of the function on lists shorter than the specified length when allow.fewer=FALSE. 2004-01-21 warnes * [r277] R/capture.R: - Mark sprint() as depreciated. - Replace references to sprint with capture.output() - Use match.arg for halign and valign arguments to textplot.default. - Fix textplot.character so that a vector of characters is properly displayed. Previouslt, character vectors were plotted on top of each other. 2003-12-03 warnes * [r253] man/foldchange.Rd: - match function argument defaults with 'usage' 2003-11-21 warnes * [r237] man/foldchange.Rd: Removed 'deqn' call that was confusing things. * [r234] man/logit.Rd: Add email address to author field * [r233] R/foldchange.R, man/foldchange.Rd: - new files * [r232] R/mixedsort.R, man/mixedsort.Rd: - Change 'T' to 'TRUE' in mixedsort.R - Add missing brace in mixedsort.Rd 2003-11-20 warnes * [r230] R/oddeven.R, man/oddeven.Rd: - Move 'odd' and 'even' functions to a separate file & provide documentation 2003-11-18 warnes * [r227] R/mixedsort.R, man/mixedsort.Rd: - Renamed smartsort to mixedsort and added documentation. 2003-11-10 warnes * [r220] R/capture.R, man/capture.Rd: - Add files contributed by Arni Magnusson . As well as some of my own. 2003-05-23 warnes * [r196] R/logit.R, man/logit.Rd: - library() backported from 1.7-devel. This version of the function adds the "pos=" argument to specify where in the search path the library should be placed. - updated .First.lib to use library(...pos=3) for MASS to avoid the 'genotype' data set in MASS from masking the genotype funciton in genetics when it loads gregmisc - Added logit() inv.logit() matchcols() function and corresponding docs 2003-04-22 warnes * [r189] man/combinations.Rd: - Fixed tpyo in example that allowed combinations(500,2) to run when it should have been ignred for testing.. 2003-04-10 warnes * [r186] man/combinations.Rd: - Added note about the need to increase options("expressions") to use large values for 'n'. Prompted by bug report from Huan Huang n provided repeat.allowed=TRUE - Bumped up version number 2002-08-01 warnes * [r114] R/running.R: - Corrected documentation mismatch for ci, ci.default. - Replaced all occurences of '_' for assignment with '<-'. - Replaced all occurences of 'T' or 'F' for 'TRUE' and 'FALSE' with the spelled out version. - Updaded version number and date. 2002-04-09 warneg * [r109] R/combinations.R, man/combinations.Rd, man/running.Rd: Checkin for version 0.5.3 2002-03-26 warneg * [r97] man/quantcut.Rd: Initial Checkin * [r96] R/quantcut.R: Initial checkin. 2002-03-20 warneg * [r91] R/RSCompat.S: - Added definition of is.R function. - Added boxplot.formula 2002-03-07 warneg * [r90] man/running.Rd: - Added documentation and example for running2 * [r89] R/running.R: - Added "running2", which handles both univariate and bivariate cases - Modified "running" to call "running2" 2002-02-05 warneg * [r75] R/RSCompat.S: - Fix typo that caused code meant to run only under S-Plus to run under R, causing problems. 2001-12-19 warneg * [r67] R/RSCompat.S: - Added code for %in%. 2001-09-18 warneg * [r18] R/RSCompat.S: Release 0.3.2 2001-09-01 warneg * [r17] R/RSCompat.S: Initial checkin. * [r16] R/running.R, man/running.Rd: Release 0.3.0 2001-08-25 warneg * [r13] R/running.R: Initial CVS checkin. * [r11] man/combinations.Rd: Fixed a typo and a syntax error. * [r7] man/running.Rd: Initial Checkin 2001-06-29 warneg * [r6] ., R, R/combinations.R, man, man/combinations.Rd: Initial revision. gtools/man/0000755000176000001440000000000012264351103012361 5ustar ripleyusersgtools/man/running.Rd0000644000176000001440000001071512261610203014330 0ustar ripleyusers% $Id: running.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{running} \alias{running} \title{Apply a Function Over Adjacent Subsets of a Vector} \description{Applies a function over subsets of the vector(s) formed by taking a fixed number of previous points.} \usage{ running(X, Y=NULL, fun=mean, width=min(length(X), 20), allow.fewer=FALSE, pad=FALSE, align=c("right", "center","left"), simplify=TRUE, by, ...) } \arguments{ \item{X}{ data vector } \item{Y}{ data vector (optional) } \item{fun}{ Function to apply. Default is \code{mean}} \item{width}{Integer giving the number of vector elements to include in the subsets. Defaults to the lesser of the length of the data and 20 elements.} \item{allow.fewer}{Boolean indicating whether the function should be computed for subsets with fewer than \code{width} points} \item{pad}{Boolean indicating whether the returned results should be 'padded' with NAs corresponding to sets with less than \code{width} elements. This only applies when when \code{allow.fewer} is FALSE.} \item{align}{One of "right", "center", or "left". This controls the relative location of `short' subsets with less then \code{width} elements: "right" allows short subsets only at the beginning of the sequence so that all of the complete subsets are at the end of the sequence (i.e. `right aligned'), "left" allows short subsets only at the end of the data so that the complete subsets are `left aligned', and "center" allows short subsets at both ends of the data so that complete subsets are `centered'. } \item{simplify}{Boolean. If FALSE the returned object will be a list containing one element per evaluation. If TRUE, the returned object will be coerced into a vector (if the computation returns a scalar) or a matrix (if the computation returns multiple values). Defaults to FALSE.} \item{by}{Integer separation between groups. If \code{by=width} will give non-overlapping windows. Default is missing, in which case groups will start at each value in the X/Y range.} \item{\dots}{ parameters to be passed to \code{fun} } } \details{ \code{running} applies the specified function to a sequential windows on \code{X} and (optionally) \code{Y}. If \code{Y} is specified the function must be bivariate. } \value{ List (if \code{simplify==TRUE}), vector, or matrix containg the results of applying the function \code{fun} to the subsets of \code{X} (\code{running}) or \code{X} and \code{Y}. Note that this function will create a vector or matrix even for objects which are not simplified by \code{sapply}. } \author{ Gregory R. Warnes \email{greg@warnes.net}, with contributions by Nitin Jain \email{nitin.jain@pfizer.com}.} \seealso{ \code{\link[gplots]{wapply}} to apply a function over an x-y window centered at each x point, \code{\link[base]{sapply}}, \code{\link[base]{lapply}} } \examples{ # show effect of pad running(1:20, width=5) running(1:20, width=5, pad=TRUE) # show effect of align running(1:20, width=5, align="left", pad=TRUE) running(1:20, width=5, align="center", pad=TRUE) running(1:20, width=5, align="right", pad=TRUE) # show effect of simplify running(1:20, width=5, fun=function(x) x ) # matrix running(1:20, width=5, fun=function(x) x, simplify=FALSE) # list # show effect of by running(1:20, width=5) # normal running(1:20, width=5, by=5) # non-overlapping running(1:20, width=5, by=2) # starting every 2nd # Use 'pad' to ensure correct length of vector, also show the effect # of allow.fewer. par(mfrow=c(2,1)) plot(1:20, running(1:20, width=5, allow.fewer=FALSE, pad=TRUE), type="b") plot(1:20, running(1:20, width=5, allow.fewer=TRUE, pad=TRUE), type="b") par(mfrow=c(1,1)) # plot running mean and central 2 standard deviation range # estimated by *last* 40 observations dat <- rnorm(500, sd=1 + (1:500)/500 ) plot(dat) sdfun <- function(x,sign=1) mean(x) + sign * sqrt(var(x)) lines(running(dat, width=51, pad=TRUE, fun=mean), col="blue") lines(running(dat, width=51, pad=TRUE, fun=sdfun, sign=-1), col="red") lines(running(dat, width=51, pad=TRUE, fun=sdfun, sign= 1), col="red") # plot running correlation estimated by last 40 observations (red) # against the true local correlation (blue) sd.Y <- seq(0,1,length=500) X <- rnorm(500, sd=1) Y <- rnorm(500, sd=sd.Y) plot(running(X,X+Y,width=20,fun=cor,pad=TRUE),col="red",type="s") r <- 1 / sqrt(1 + sd.Y^2) # true cor of (X,X+Y) lines(r,type="l",col="blue") } \keyword{misc} gtools/man/gtools-deprecated.Rd0000644000176000001440000000106212261610203016250 0ustar ripleyusers\name{gtools-deprecated} \alias{gtools-deprecated} \title{Deprecated Functions in the gtools package} \description{ These functions are provided for compatibility with older versions of gtools, and may be defunct as soon as the next release. } %\usage{ %} %\arguments{ %} \details{ gtools currently contains no deprecated functions. % The original help page for these functions is often % available at \code{help("oldName-deprecated")} (note the quotes). % % \itemize{ % \item{} % } } \seealso{ \code{\link{Deprecated}} } \keyword{misc} gtools/man/setTCPNoDelay.Rd0000644000176000001440000000336612261610203015272 0ustar ripleyusers\name{setTCPNoDelay} \alias{setTCPNoDelay} \title{Modify the TCP\_NODELAY (`de-Nagle') flag for socket objects} \description{ Modify the TCP\_NODELAY (`de-Nagele') flag for socket objects } \usage{ setTCPNoDelay(socket, value=TRUE) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{socket}{A socket connection object} \item{value}{Logical indicating whether to set (\code{TRUE}) or unset (\code{FALSE}) the flag} } \details{ By default, TCP connections wait a small fixed interval before actually sending data, in order to permit small packets to be combined. This algorithm is named after its inventor, John Nagle, and is often referred to as 'Nagling'. While this reduces network resource utilization in these situations, it imposes a delay on all outgoing message data, which can cause problems in client/server situations. This function allows this feature to be disabled (de-Nagling, \code{value=TRUE}) or enabled (Nagling, \code{value=FALSE}) for the specified socket. } \value{ The character string "SUCCESS" will be returned invisible if the operation was succesful. On failure, an error will be generated. } \references{ "Nagle's algorithm" at WhatIS.com \url{ http://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci754347,00.html} Nagle, John. "Congestion Control in IP/TCP Internetworks", IETF Request for Comments 896, January 1984. \url{http://www.ietf.org/rfc/rfc0896.txt?number=896} } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link{make.socket}}, \code{\link{socketConnection}} } \examples{ \dontrun{ s <- make.socket(host='www.r-project.org', port=80) setTCPNoDelay(s, value=TRUE) } } \keyword{programming} \keyword{misc} \keyword{utilities} gtools/man/ask.Rd0000644000176000001440000000147612261610203013432 0ustar ripleyusers\name{ask} \alias{ask} \title{Display a prompt and collect the user's response} \description{ Display a prompt and collect the user's response } \usage{ ask(msg = "Press to continue: ") } \arguments{ \item{msg}{Character vetor providing the message to be displayed} } \details{ The prompt message will be displayed, and then \code{readLines} is used to collect a single input value (possibly empty), which is then returned. } \value{ A character scalar containing the input providede by the user. } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link{readLines}}, \code{\link{scan}} } \examples{ # use default prompt ask() silly <- function() { age <- ask("How old aroe you? ") age <- as.numeric(age) cat("In 10 years you will be", age+10, "years old!\n") } } \keyword{IO} gtools/man/defmacro.Rd0000644000176000001440000001044312261610203014426 0ustar ripleyusers\name{defmacro} \alias{defmacro} \alias{strmacro} \title{Define a macro} \description{ \code{defmacro} define a macro that uses R expression replacement \code{strmacro} define a macro that uses string replacement } \usage{ defmacro(..., expr) strmacro(..., expr, strexpr) } \arguments{ \item{\dots}{ macro argument list } \item{expr}{ R expression defining the macro body } \item{strexpr}{ character string defining the macro body } } \details{ \code{defmacro} and \code{strmacro} create a macro from the expression given in \code{expr}, with formal arguments given by the other elements of the argument list. A macro is similar to a function definition except for handling of formal arguments. In a function, formal arguments are simply variables that contains the result of evaluating the expressions provided to the function call. In contrast, macros actually modify the macro body by \emph{replacing} each formal argument by the expression (\code{defmacro}) or string (\code{strmacro}) provided to the macro call. For \code{defmacro}, the special argument name \code{DOTS} will be replaced by \code{...} in the formal argument list of the macro so that \code{...} in the body of the expression can be used to obtain any additional arguments passed to the macro. For \code{strmacro} you can mimic this behavior providing a \code{DOTS=""} argument. This is illustrated by the last example below. Macros are often useful for creating new functions during code execution. } \note{ Note that because [the defmacro code] works on the parsed expression, not on a text string, defmacro avoids some of the problems of traditional string substitution macros such as \code{strmacro} and the C preprocessor macros. For example, in \preformatted{ mul <- defmacro(a, b, expr={a*b}) } a C programmer might expect \code{mul(i, j + k)} to expand (incorrectly) to \code{i*j + k}. In fact it expands correctly, to the equivalent of \code{i*(j + k)}. For a discussion of the differences between functions and macros, please Thomas Lumley's R-News article (reference below). } \value{ A macro function. } \references{ The original \code{defmacro} code was directly taken from: Lumley T. "Programmer's Niche: Macros in R", R News, 2001, Vol 1, No. 3, pp 11--13, \url{http://CRAN.R-project.org/doc/Rnews/} } \author{ Thomas Lumley wrote \code{defmacro}. Gregory R. Warnes \email{greg@warnes.net} enhanced it and created \code{strmacro}. } \seealso{ \code{\link[base]{function}} \code{\link[base]{substitute}}, \code{\link[base]{eval}}, \code{\link[base]{parse}}, \code{\link[base]{source}}, \code{\link[base]{parse}}, } \examples{ #### # macro for replacing a specified missing value indicator with NA # within a dataframe ### setNA <- defmacro(df, var, values, expr={ df$var[df$var \%in\% values] <- NA }) # create example data using 999 as a missing value indicator d <- data.frame( Grp=c("Trt", "Ctl", "Ctl", "Trt", "Ctl", "Ctl", "Trt", "Ctl", "Trt", "Ctl"), V1=c(1, 2, 3, 4, 5, 6, 999, 8, 9, 10), V2=c(1, 1, 1, 1, 1, 2, 999, 2, 999, 999) ) d # Try it out setNA(d, V1, 999) setNA(d, V2, 999) d ### # Expression macro ### plot.d <- defmacro( df, var, DOTS, col="red", title="", expr= plot( df$var ~ df$Grp, type="b", col=col, main=title, ... ) ) plot.d( d, V1) plot.d( d, V1, col="blue" ) plot.d( d, V1, lwd=4) # use optional 'DOTS' argument ### # String macro (note the quoted text in the calls below) # # This style of macro can be useful when you are reading # function arguments from a text file ### plot.s <- strmacro( DF, VAR, COL="'red'", TITLE="''", DOTS="", expr= plot( DF$VAR ~ DF$Grp, type="b", col=COL, main=TITLE, DOTS) ) plot.s( "d", "V1") plot.s( DF="d", VAR="V1", COL='"blue"' ) plot.s( "d", "V1", DOTS='lwd=4') # use optional 'DOTS' argument ####### # Create a macro that defines new functions ###### plot.sf <- defmacro(type='b', col='black', title=deparse(substitute(x)), DOTS, expr= function(x,y) plot( x,y, type=type, col=col, main=title, ...) ) plot.red <- plot.sf(col='red',title='Red is more Fun!') plot.blue <- plot.sf(col='blue',title="Blue is Best!", lty=2) plot.red(1:100,rnorm(100)) plot.blue(1:100,rnorm(100)) } \keyword{programming} gtools/man/combinations.Rd0000644000176000001440000000406212261610203015333 0ustar ripleyusers% $Id: combinations.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{combinations} \alias{combinations} \alias{permutations} \title{Enumerate the Combinations or Permutations of the Elements of a Vector} \description{ \code{combinations} enumerates the possible combinations of a specified size from the elements of a vector. \code{permutations} enumerates the possible permutations. } \usage{ combinations(n, r, v=1:n, set=TRUE, repeats.allowed=FALSE) permutations(n, r, v=1:n, set=TRUE, repeats.allowed=FALSE) } %- maybe also `usage' for other objects documented here. \arguments{ \item{n}{ Size of the source vector } \item{r}{ Size of the target vectors } \item{v}{ Source vector. Defaults to \code{1:n}} \item{set}{ Logical flag indicating whether duplicates should be removed from the source vector \code{v}. Defaults to \code{TRUE}.} \item{repeats.allowed}{ Logical flag indicating whether the constructed vectors may include duplicated values. Defaults to \code{FALSE}. } } \details{ Caution: The number of combinations and permutations increases rapidly with \code{n} and \code{r}!. To use values of \code{n} above about 45, you will need to increase R's recursion limit. See the \code{expression} argument to the \code{options} command for details on how to do this. } \value{ Returns a matrix where each row contains a vector of length \code{r}. } \references{Venables, Bill. "Programmers Note", R-News, Vol 1/1, Jan. 2001. \url{http://cran.r-project.org/doc/Rnews} } \author{ Original versions by Bill Venables \email{Bill.Venables@cmis.csiro.au}. Extended to handle \code{repeats.allowed} by Gregory R. Warnes \email{greg@warnes.net}. } \seealso{ \code{\link[base]{choose}}, \code{\link[base]{options}} } \examples{ combinations(3,2,letters[1:3]) combinations(3,2,letters[1:3],repeats=TRUE) permutations(3,2,letters[1:3]) permutations(3,2,letters[1:3],repeats=TRUE) # To use large 'n', you need to change the default recusion limit options(expressions=1e5) cmat <- combinations(300,2) dim(cmat) # 44850 by 2 } \keyword{ manip } gtools/man/smartbind.Rd0000644000176000001440000000510412261610203014627 0ustar ripleyusers\name{smartbind} \alias{smartbind} \title{Efficient rbind of data framesy, even if the column names don't match} \description{ Efficient rbind of data frames, even if the column names don't match } \usage{ smartbind(..., fill=NA, sep=':', verbose=FALSE) } \arguments{ \item{\dots}{Data frames to combine} \item{fill}{Value to use when 'filling' missing columns. Defaults to \code{NA}. } \item{sep}{Character string used to separate column names when pasting them together.} \item{verbose}{Logical flag indicating whether to display processing messages. Defaults to \code{FALSE}.} } \value{ The returned data frame will contain: \item{columns}{all columns present in any provided data frame} \item{rows}{a set of rows from each provided data frame, with values in columns not present in the given data frame filled with missing (\code{NA}) values.} The data type of columns will be preserved, as long as all data frames with a given column name agree on the data type of that column. If the data frames disagree, the column will be converted into a character strings. The user will need to coerce such character columns into an appropriate type. } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link{rbind}}, \code{\link{cbind}} } \examples{ df1 <- data.frame(A=1:10, B=LETTERS[1:10], C=rnorm(10) ) df2 <- data.frame(A=11:20, D=rnorm(10), E=letters[1:10] ) # rbind would fail \dontrun{ rbind(df1, df2) # Error in match.names(clabs, names(xi)) : names do not match previous # names: # D, E } # but smartbind combines them, appropriately creating NA entries smartbind(df1, df2) # specify fill=0 to put 0 into the missing row entries smartbind(df1, df2, fill=0) \dontshow{ n=10 # number of data frames to create s=10 # number of rows in each data frame # create a bunch of column names names <- LETTERS[2:5] # create a list 'Z' containing 'n' data frames, each with 3 columns # and 's' rows. The first column is always named 'A', but the other # two have a names randomly selected from 'names' Z <- list() for(i in 1:n) { X <- data.frame(A=sample(letters,s,replace=TRUE), B=letters[1:s], C=rnorm(s) ) colnames(X) <- c("A",sample(names,2,replace=FALSE)) Z[[i]] <- X } # Error in match.names(clabs, names(xi)) : names do not match # previous names: E # But smartbind will 'do the right thing' df <- do.call("smartbind",Z) df } } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. \keyword{manip} gtools/man/gtools-defunct.Rd0000644000176000001440000000150212264351674015620 0ustar ripleyusers\name{gtools-defunct} \alias{gtools-defunct} \alias{assert} \alias{addLast} \alias{capture} \alias{sprint} \title{Defunct Functions in package \code{gtools}} \description{ The functions or variables listed here are no longer part of package \code{gtools}. } \details{ \itemize{ \item{ \code{assert} is a defunct synonym for \code{\link[base]{stopifnot}}. } \item{ \code{addLast} has been replaced by \code{lastAdd}, which has the same purpose but appled using different syntax. } \item{ \code{capture} and \code{capture.output} have been removed in favor of \code{capture.output} from the \code{utils} package.} } } \seealso{ \code{\link[base]{Defunct}}, \code{\link[base]{stopifnot}}, \code{\link[gtools]{lastAdd}}, \code{\link[utils]{capture.output}} } \keyword{misc} gtools/man/dirichlet.Rd0000644000176000001440000000272512261610203014621 0ustar ripleyusers% $Id: dirichlet.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{rdirichlet} \alias{rdirichlet} \alias{ddirichlet} \title{Functions for the Dirichlet Distribution} \description{ Functions to compute the density of or generate random deviates from the Dirichlet distribution. } \usage{ rdirichlet(n, alpha) ddirichlet(x, alpha) } \arguments{ \item{x}{A vector containing a single random deviate or matrix containg one random deviate per row.} \item{n}{Number of random vectors to generate. } \item{alpha}{Vector or (for \code{ddirichlet}) matrix containing shape parameters. } } \details{ The Dirichlet distribution is the multidimensional generalization of the beta distribution. It is the canonical Bayesian distribution for the parameter estimates of a multinomial distribution. } \value{ \code{ddirichlet} returns a vector containing the Dirichlet density for the corresponding rows of \code{x}. \code{rdirichlet} returns a matrix with \code{n} rows, each containing a single Dirichlet random deviate. } \author{ Code original posted by Ben Bolker to R-News on Fri Dec 15 2000. See \url{http://www.r-project.org/nocvs/mail/r-help/2000/3865.html}. Ben attributed the code to Ian Wilson \email{i.wilson@maths.abdn.ac.uk}. Subsequent modifications by Gregory R. Warnes \email{greg@warnes.net}. } \seealso{ \code{\link{dbeta}}, \code{\link{rbeta}} } \examples{ x <- rdirichlet(20, c(1,1,1) ) ddirichlet(x, c(1,1,1) ) } \keyword{distribution} gtools/man/stars.pval.Rd0000644000176000001440000000162612264347454014770 0ustar ripleyusers\name{stars.pval} \alias{stars.pval} \title{ Generate significance stars from p-values } \description{ Generate significance stars (e.g. '***', '**', '*', '+') from p-values using R's standard definitions. } \usage{ stars.pval(p.value) } \arguments{ \item{p.value}{numeric vector of p-values} } \details{ Mapping from p-value ranges to symbols: \describe{ \item{0 - 0.001}{'***'} \item{0.001 - 0.01}{'**'} \item{0.01 - 0.05}{'*'} \item{0.05 - 0.1}{'+'} \item{0.1 - 1.0}{'' (No symbol)} } } \value{ A character vector containing the same number of elements as \code{p-value}, with an attribute "legend" providing the conversion pattern. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[stats]{symnum}} } \examples{ p.val <- c(0.0004, 0.0015, 0.013, 0.044, 0.067, 0.24) stars.pval(p.val) } \keyword{misc} gtools/man/logit.Rd0000644000176000001440000000234612261610203013767 0ustar ripleyusers% $Id: logit.Rd 1695 2013-07-05 23:33:15Z warnes $ % \name{logit} \alias{logit} \alias{inv.logit} \title{Generalized logit and inverse logit function} \description{ Compute generalized logit and generalized inverse logit functions. } \usage{ logit(x, min = 0, max = 1) inv.logit(x, min = 0, max = 1) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{x}{value(s) to be transformed} \item{min}{Lower end of logit interval} \item{max}{Upper end of logit interval} } \details{ The generalized logit function takes values on [min, max] and transforms them to span [-Inf,Inf] it is defined as: \deqn{y = log(\frac{p}{(1-p)})}{y = log(p/(1-p))} where \deqn{p=\frac{(x-min)}{(max-min)}}{p=(x-min)/(max-min)} The generized inverse logit function provides the inverse transformation: \deqn{x = p' (max-min) + min}{x = p * (max-min) + min} where \deqn{p'=\frac{exp(y)}{(1+exp(y))}}{exp(y)/(1+exp(y))} } \value{ Transformed value(s). } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[car]{logit}} } \examples{ x <- seq(0,10, by=0.25) xt <- logit(x, min=0, max=10) cbind(x,xt) y <- inv.logit(xt, min=0, max=10) cbind(x,xt,y) } \keyword{math} gtools/man/permute.Rd0000644000176000001440000000105012261610203014321 0ustar ripleyusers% $Id: permute.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{permute} \alias{permute} \title{Randomly Permute the Elements of a Vector} \description{ Randomly Permute the elements of a vector } \usage{ permute(x) } \arguments{ \item{x}{ Vector of items to be permuted } } \details{ This is simply a wrapper function for \code{\link{sample}}. } \value{ Vector with the original items reordered. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link{sample}} } \examples{ x <- 1:10 permute(x) } \keyword{distribution} gtools/man/scat.Rd0000644000176000001440000000137012261610203013577 0ustar ripleyusers% $Id: scat.Rd 1433 2010-05-01 22:03:03Z warnes $ \name{scat} \alias{scat} %- Also NEED an '\alias' for EACH other topic documented here. \title{Display debugging text} \description{ If \code{getOption('DEBUG')==TRUE}, write text to STDOUT and flush so that the text is immediatly displayed. Otherwise, do nothing. } \usage{ scat(...) } \arguments{ \item{\dots}{Arguments passed to \code{cat}} } \value{ NULL (invisibly) } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link[base]{cat}}} \examples{ options(DEBUG=NULL) # makee sure DEBUG isn't set scat("Not displayed") options(DEBUG=TRUE) scat("This will be displayed immediately (even in R BATCH output \n") scat("files), provided options()$DEBUG is TRUE.") } \keyword{print} gtools/man/mixedsort.Rd0000644000176000001440000000427012261610203014665 0ustar ripleyusers% $Id: mixedsort.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{mixedsort} \alias{mixedsort} \alias{mixedorder} \title{Order or Sort strings with embedded numbers so that the numbers are in the correct order} \description{ These functions sort or order character strings containing numbers so that the numbers are numerically sorted rather than sorted by character value. I.e. "Asprin 50mg" will come before "Asprin 100mg". In addition, case of character strings is ignored so that "a", will come before "B" and "C". } \usage{ mixedsort(x) } \arguments{ \item{x}{ Character vector to be sorted } } \details{ I often have character vectors (e.g. factor labels) that contain both text and numeric data, such as compound and dose. This function is useful for sorting these character vectors into a logical order. It does so by splitting each character vector into a sequence of character and numeric sections, and then sorting along these sections, with numbers being sorted by numeric value (e.g. "50" comes before "100"), followed by characters strings sorted by character value (e.g. "A" comes before "B"). Empty strings are always sorted to the front of the list, and \code{NA} values to the end. } \value{ \code{mixedorder} returns a vector giving the sort order of the input elements. \code{mixedsort} returns the sorted vector. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[base]{sort}}, \code{\link[base]{order}} } \examples{ # compound & dose labels Treatment <- c("Control", "Asprin 10mg/day", "Asprin 50mg/day", "Asprin 100mg/day", "Acetomycin 100mg/day", "Acetomycin 1000mg/day") # ordinary sort puts the dosages in the wrong order sort(Treatment) # but mixedsort does the 'right' thing mixedsort(Treatment) # Here is a more complex example x <- rev(c("AA 0.50 ml", "AA 1.5 ml", "AA 500 ml", "AA 1500 ml", "EXP 1", "AA 1e3 ml", "A A A", "1 2 3 A", "NA", NA, "1e2", "", "-", "1A", "1 A", "100", "100A", "Inf")) mixedorder(x) mixedsort(x) # notice that plain numbers, including 'Inf' show up before strings. } \keyword{univar} \keyword{manip} \concept{natural sort} \concept{dictionary sort} gtools/man/binsearch.Rd0000644000176000001440000001001712261610203014601 0ustar ripleyusers% $Id: binsearch.Rd 1087 2006-11-11 04:09:59Z warnes $ \name{binsearch} \alias{binsearch} \title{Binary Search} \description{ Search within a specified range to locate an integer parameter which results in the the specified monotonic function obtaining a given value. } \usage{ binsearch(fun, range, ..., target = 0, lower = ceiling(min(range)), upper = floor(max(range)), maxiter = 100, showiter = FALSE) } \arguments{ \item{fun}{Monotonic function over which the search will be performed.} \item{range}{2-element vector giving the range for the search.} \item{\dots}{Additional parameters to the function \code{fun}.} \item{target}{Target value for \code{fun}. Defaults to 0.} \item{lower}{Lower limit of search range. Defaults to \code{min(range)}.} \item{upper}{Upper limit of search range. Defaults to \code{max(range)}.} \item{maxiter}{ Maximum number of search iterations. Defaults to 100.} \item{showiter}{ Boolean flag indicating whether the algorithm state should be printed at each iteration. Defaults to FALSE.} } \details{ This function implements an extension to the standard binary search algorithm for searching a sorted list. The algorithm has been extended to cope with cases where an exact match is not possible, to detect whether that the function may be monotonic increasing or decreasing and act appropriately, and to detect when the target value is outside the specified range. The algorithm initializes two variable \code{lo} and \code{high} to the extremes values of \code{range}. It then generates a new value \code{center} halfway between \code{lo} and \code{hi}. If the value of \code{fun} at \code{center} exceeds \code{target}, it becomes the new value for \code{lo}, otherwise it becomes the new value for \code{hi}. This process is iterated until \code{lo} and \code{hi} are adjacent. If the function at one or the other equals the target, this value is returned, otherwise \code{lo}, \code{hi}, and the function value at both are returned. Note that when the specified target value falls between integers, the \emph{two} closest values are returned. If the specified target falls outside of the specified \code{range}, the closest endpoint of the range will be returned, and an warning message will be generated. If the maximum number if iterations was reached, the endpoints of the current subset of the range under consideration will be returned. } \value{ A list containing: \item{call}{How the function was called.} \item{numiter}{The number of iterations performed} \item{flag }{One of the strings, "Found", "Between Elements", "Maximum number of iterations reached", "Reached lower boundary", or "Reached upper boundary."} \item{where}{One or two values indicating where the search terminated.} \item{value}{Value of the function \code{fun} at the values of \code{where}.} } %\references{ ~put references to the literature/web site here ~ } \author{Gregory R. Warnes \email{greg@warnes.net} } \note{This function often returns two values for \code{where} and \code{value}. Be sure to check the \code{flag} parameter to see what these values mean.} \seealso{ \code{\link{optim}}, \code{\link{optimize}}, \code{\link{uniroot}} } \examples{ ### Toy examples # search for x=10 binsearch( function(x) x-10, range=c(0,20) ) # search for x=10.1 binsearch( function(x) x-10.1, range=c(0,20) ) ### Classical toy example # binary search for the index of 'M' among the sorted letters fun <- function(X) ifelse(LETTERS[X] > 'M', 1, ifelse(LETTERS[X] < 'M', -1, 0 ) ) binsearch( fun, range=1:26 ) # returns $where=13 LETTERS[13] ### Substantive example, from genetics \dontrun{ library(genetics) # Determine the necessary sample size to detect all alleles with # frequency 0.07 or greater with probability 0.95. power.fun <- function(N) 1 - gregorius(N=N, freq=0.07)$missprob binsearch( power.fun, range=c(0,100), target=0.95 ) # equivalent to gregorius( freq=0.07, missprob=0.05) } } \keyword{optimize} \keyword{programming} gtools/man/oddeven.Rd0000644000176000001440000000066612261610203014300 0ustar ripleyusers% $Id: oddeven.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{odd} \alias{odd} \alias{even} \title{Detect odd/even integers } \description{ detect odd/even integers } \usage{ odd(x) even(x) } \arguments{ \item{x}{ vector of integers } } \value{ Vector of TRUE/FALSE values. } \author{ Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link[base]{round}} } \examples{ odd(4) even(4) odd(1:10) even(1:10) } \keyword{arith} gtools/man/quantcut.Rd0000644000176000001440000000363112261610203014513 0ustar ripleyusers% $Id: quantcut.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{quantcut} \alias{quantcut} \title{ Create a Factor Variable Using the Quantiles of a Continuous Variable} \description{ Create a factor variable using the quantiles of a continous variable. } \usage{ quantcut(x, q=seq(0,1,by=0.25), na.rm=TRUE, ...) } %- maybe also `usage' for other objects documented here. \arguments{ \item{x}{ Continous variable. } \item{q}{ Vector of quantiles used for creating groups. Defaults to \code{seq(0, 1, by=0.25)}. See \code{\link{quantile}} for details. } \item{na.rm}{ Boolean indicating whether missing values should be removed when computing quantiles. Defaults to TRUE.} \item{\dots}{ Optional arguments passed to \code{\link{cut}}. } } \details{ This function uses \code{\link{quantile}} to obtain the specified quantiles of \code{x}, then calls \code{\link{cut}} to create a factor variable using the intervals specified by these quantiles. It properly handles cases where more than one quantile obtains the same value, as in the second example below. Note that in this case, there will be fewer generated factor levels than the specified number of quantile intervals. } \value{ Factor variable with one level for each quantile interval given by \code{q}. } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link{cut}}, \code{\link{quantile}} } \examples{ ## create example data \testonly{ set.seed(1234) } x <- rnorm(1000) ## cut into quartiles quartiles <- quantcut( x ) table(quartiles) ## cut into deciles deciles <- quantcut( x, seq(0,1,by=0.1) ) table(deciles) ## show handling of 'tied' quantiles. x <- round(x) # discretize to create ties stem(x) # display the ties deciles <- quantcut( x, seq(0,1,by=0.1) ) table(deciles) # note that there are only 5 groups (not 10) # due to duplicates } \keyword{ manip } gtools/man/lastAdd.Rd0000644000176000001440000000364212261610203014225 0ustar ripleyusers\name{lastAdd} \alias{lastAdd} \title{Non-destructively construct a .Last function to be executed when R exits.} \description{ Non-destructively construct a \code{.Last} function to be executed when R exits. } \usage{ lastAdd(fun) } \arguments{ \item{fun}{Function to be called.} } \details{ \code{lastAdd} constructs a new function which can be used to replace the exising definition of \code{.Last}, which will be executed when R terminates normally. If a \code{.Last} function already exists in the global environment, the original definition is stored in a private environment, and the new function is defined to call the function \code{fun} and then to call the previous (stored) definition of \code{.Last}. If no \code{.Last} function exists in the global environment, \code{lastAdd} simply returns the function \code{fun}. } \note{ This function replaces the (now defunct) \code{addLast} function. } \value{ A new function to be used for \code{.Last}. } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link[base]{.Last}} } \examples{ ## Print a couple of cute messages when R exits. helloWorld <- function() cat("\nHello World!\n") byeWorld <- function() cat("\nGoodbye World!\n") .Last <- lastAdd(byeWorld) .Last <- lastAdd(helloWorld) \dontshow{ .Last() } \dontrun{ q("no") ## Should yield: ## ## Save workspace image? [y/n/c]: n ## ## Hello World! ## ## Goodbye World! ## ## Process R finished at Tue Nov 22 10:28:55 2005 } ## Unix-flavour example: send Rplots.ps to printer on exit. myLast <- function() { cat("Now sending PostScript graphics to the printer:\n") system("lpr Rplots.ps") cat("bye bye...\n") } .Last <- lastAdd(myLast) \dontshow{ .Last() } \dontrun{ quit("yes") ## Should yield: ## ## Now sending PostScript graphics to the printer: ## lpr: job 1341 queued ## bye bye... ## ## Process R finished at Tue Nov 22 10:28:55 2005 } } \keyword{programming} gtools/man/foldchange.Rd0000644000176000001440000000305112261610203014735 0ustar ripleyusers% $Id: foldchange.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{foldchange} \alias{foldchange} \alias{logratio2foldchange} \alias{foldchange2logratio} \title{Compute fold-change or convert between log-ratio and fold-change.} \description{ \code{foldchange} computes the fold change for two sets of values. \code{logratio2foldchange} converts values from log-ratios to fold changes. \code{foldchange2logratio} does the reverse. } \usage{ foldchange(num,denom) logratio2foldchange(logratio, base=2) foldchange2logratio(foldchange, base=2) } \arguments{ \item{num,denom}{vector/matrix of numeric values} \item{logratio}{vector/matrix of log-ratio values} \item{foldchange}{vector/matrix of fold-change values} \item{base}{Exponential base for the log-ratio.} } \details{ Fold changes are commonly used in the biological sciences as a mechanism for comparing the relative size of two measurements. They are computed as: \eqn{\frac{num}{denom}}{num/denom} if \eqn{num>denom}, and as \eqn{\frac{-denom}{num}}{-denom/num} otherwise. Fold-changes have the advantage of ease of interpretation and symmetry about \eqn{num=denom}, but suffer from a discontinuty between -1 and 1, which can cause significant problems when performing data analysis. Consequently statisticians prefer to use log-ratios. } \value{ A vector or matrix of the same dimensions as the input containing the converted values. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \examples{ a <- 1:21 b <- 21:1 f <- foldchange(a,b) cbind(a,b,f) } \keyword{math} gtools/man/invalid.Rd0000644000176000001440000000154112261610203014273 0ustar ripleyusers% $Id: invalid.Rd 1433 2010-05-01 22:03:03Z warnes $ % \name{invalid} \alias{invalid} \title{Test if a value is missing, empty, or contains only NA or NULL values} \description{ Test if a value is missing, empty, or contains only NA or NULL values. } \usage{ invalid(x) } \arguments{ \item{x}{value to be tested} } %\details{ %} \value{ Logical value. } \author{Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[base]{missing}}, \code{\link[base]{is.na}}, \code{\link[base]{is.null}} } \examples{ invalid(NA) invalid() invalid(c(NA,NA,NULL,NA)) invalid(list(a=1,b=NULL)) # example use in a function myplot <- function(x,y) { if(invalid(y)) { y <- x x <- 1:length(y) } plot(x,y) } myplot(1:10) myplot(1:10,NA) } \keyword{programming} gtools/man/checkRVersion.Rd0000644000176000001440000000251312261610203015412 0ustar ripleyusers\name{checkRVersion} \alias{checkRVersion} \title{Check if a newer version of R is available} \description{ Check if a newer version of R is available } \usage{ checkRVersion(quiet = FALSE) } \arguments{ \item{quiet}{Logical indicating whether printed output should be supressed.} } \details{ This function accesses the R web site to discover the latest released version of R. It then compares this version to the running version. If the running version is the same as the latest version, it prints the message, "The latest version of R is installed:" followed by the version number, and returns NULL. If the running version is older than the current version, it displays the message, "A newer version of R is now available:" followed by the corresponding version number, and returns the version number. If \code{quiet=TRUE}, no printing is performed. } \value{ Either the version number of the latest version of R, if the running version is less than the latest version, or NULL. } \author{Gregory R. Warnes \email{gregory.warnes@rochester.edu>}} \note{ This function utilizes the internet to access the R project web site. If internet access is unavailable, the function will fail. } \seealso{ \code{\link[base]{R.Version}} } \examples{ checkRVersion() ver <- checkRVersion() print(ver) } \keyword{utilities} gtools/man/ELISA.Rd0000644000176000001440000000160012261610203013476 0ustar ripleyusers% $Id: ELISA.Rd 1012 2006-11-14 22:25:06Z ggorjan $ % \name{ELISA} \docType{data} \alias{ELISA} \title{Data from an ELISA assay} \description{Observed signals and (for some observations) nominal concentrations for samples that were aliquoted to multiple assay plates, which were read multiple times on multiple days. } \usage{ data(ELISA) } \format{a data frame with the following columns: \itemize{ \item{PlateDay}{factor. Specifies one of four physically disctinct 96 well plates} \item{Read}{factor. The signal was read 3 times for each plate.} \item{Description}{character. Indicates contents of sample.} \item{Concentration}{numeric. Nominal concentration of standards (NA for all other samples).} \item{Signal}{numeric. Assay signal. Specifically, optical density (a colorimetric assay).} } } \source{Anonymized data. } \keyword{datasets} gtools/man/keywords.Rd0000644000176000001440000000121512261610203014512 0ustar ripleyusers\name{keywords} \alias{keywords} \title{List valid keywords for R man pages} \description{ List valid keywords for R man pages } \usage{ keywords(topic) } \arguments{ \item{topic}{object or man page topic} } \details{ If \code{topic} is provided, return a list of the keywords associated with \code{topic}. Otherwise, display the list of valid R keywords from the R doc/KEYWORDS file. } \author{Gregory R. Warnes \email{greg@warnes.net}} \seealso{ \code{\link[utils]{help}} } \examples{ ## Show all valid R keywords keywords() ## Show keywords associated with the 'merge' function keywords(merge) keywords("merge") } \keyword{documentation}