gtools/0000755000176000001440000000000012532022430011602 5ustar ripleyusersgtools/inst/0000755000176000001440000000000012531372110012561 5ustar ripleyusersgtools/inst/NEWS0000644000176000001440000002003412531224511013260 0ustar ripleyusersgtools 3.5.0 - 2015-04-28 ------------------------- New Functions: - New roman2int() functon to convert roman numerals to integers without the range restriction of utils::as.roman(). - New asc() and chr() functions to convert between ASCII codes and characters. (Based on the 'Data Debrief' blog entry for 2011-03-09 at http://datadebrief.blogspot.com/2011/03/ascii-code-table-in-r.html). - New unByteCode() and unByteCodeAssign() functions to convert a byte-code functon to an interpeted code function. - New assignEdgewise() function for making assignments into locked environments. (Used by unByteCodeAssign().) Enhacements: - mixedsort() and mixedorder() now have arguments 'decreasing', 'na.last', and 'blank.last' arguments to control sort ordering. - mixedsort() and mixedirdeR() now support Roman numerals via the arguments 'numeric.type', and 'roman.case'. (Request by David Winsemius, suggested code changes by Henrik Bengtsson.) - speed up mixedorder() (and hence mixedsort()) by moving suppressWarnings() outside of lapply loops. (Suggestion by Henrik Bengtsson.) - The 'q' argument to quantcut() now accept an integer indicating the number of equally spaced quantile groups to create. (Suggestion and patch submitted by Ryan C. Thompson.) Bug fixes: - Removed stray browser() call in smartbind(). - ddirichlet(x, alpha) was incorrectly returning NA when for any i, x[i]=0 and alpha[i]=1. (Bug report by John Nolan.) Other changes: - Correct typographical errors in package description. gtools 3.4.2 - 2015-04-06 ------------------------- New features: - New function loadedPackages() to display name, version, and path of loaded packages (package namespaces). - New function: na.replace() to replace missing values within a vector with a specified value.` Bug fixes: - Modify keywords() to work properly in R 3.4.X and later. gtools 3.4.1 - 2014-05-27 ------------------------- Bug fixes: - smartbind() now converts all non-atomic type columns (except factor) to type character instead of generating an opaque error message. Other changes: - the argument to ASCIIfy() is now named 'x' instead of 'string'. - minor formatting changes to ASCIIfy() man page. gtools 3.4.0 - 2014-04-14 ------------------------- New features: - New ASCIIfy() function to converts character vectors to ASCII representation by escaping them as \x00 or \u0000 codes. Contributed by Arni Magnusson. gtools 3.3.1 - 2014-03-01 ------------------------- Bug fixes: - 'mixedorder' (and hence 'mixedsort') not properly handling single-character strings between numbers, so that '1a2' was being handled as a single string rather than being properly handled as c('1', 'a', '2'). gtools 3.3.0 - 2014-02-11 ------------------------- New features: - Add the getDependencies() function to return a list of dependencies for the specified package(s). Includes arguments to control whether these dependencies should be constructed using information from locally installed packages ('installed', default is TRUE), avilable CRAN packages ('available', default is TRUE) and whether to include base ('base', default=FALSE) and recommended ('recommended', default is FALSE) packages. Bug fixes: - binsearch() was returning the wrong endpoint & value when the found value was at the upper endpoint. gtools 3.2.1 - 2014-01-13 ------------------------- Bug fixes: - Resolve circular dependency with gdata gtools 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/ChangeLog0000644000176000001440000005311112531224511014335 0ustar ripleyusers2015-05-27 warnes * [r2039] R/mixedsort.R, man/mixedsort.Rd: Add roman numeral support to mixedorder() and mixedsort(). * [r2037] man/asc.Rd: Add asc() and chr() functions for converting between characters and ASCII codes * [r2036] R/roman2int.R: roman2int() now returns NA for invalid roman numeral strings instead of generating an error. * [r2035] NAMESPACE: Add asc(), chr(), assignEdgewise(), unByteCode(), and unByteCodeAssign() to package NAMESPACE. * [r2034] R/asc.R: Add asc() and chr() functions for converting between characters and ASCII codes 2015-05-26 warnes * [r2030] inst/ChangeLog: Add changelog to svn repository 2015-05-25 warnes * [r2029] tests/test_ddirichlet.R: Add library call. * [r2028] man/unByteCode.Rd: Fix typo and add documentation for argument 'name'. * [r2027] man/mixedsort.Rd: Fix typo. * [r2026] man/mixedsort.Rd: Add description of blanklast argument, fix typo. * [r2025] man/quantcut.Rd: Change usage to match actual definition. * [r2024] man/mixedsort.Rd: Note characters sorting ignores case. * [r2023] man/mixedsort.Rd: Remove '...' from arglist to match source code. * [r2022] man/mixedsort.Rd: Replace unicode quotes with \code{..}. 2015-05-23 warnes * [r2021] tests/test_ddirichlet.R: Add regression test ddirichlet() bug for x[i]=0, alpha[i]=1: ddirichlet(x, alpha) was returning NA rather than 0. * [r2020] R/dirichlet.R: ddirichlet() was incorrectly returning NA when x[i]=0 and alpha[i]=1. In this case, the one calculation became (-Inf * 0), which R evaluates to NaN. The correction is to detect this case and substitute -Inf instead of NaN. 2015-05-08 warnes * [r2019] R/mixedsort.R: Summary: Speed up mixedorder by moving suppressWarnings outside of lapply loops. (Suggestion by Henrik Bengtsson.) 2015-05-02 warnes * [r2018] Rename 'trunk' to 'pkg' for compatibility with R-forge * [r2017] Minor layout change. * [r2016] Remove stray 'svn' that was inserted into the code. * [r2015] Add man page for unByteCode(), assignEdgeWise(), and unByteCodeAssign() 2015-04-28 warnes * [r1976] Changes to mixedsort(): - Hands off objects that are not character vectors to the default sort. - Add 'decreasing', 'na.last', and 'blank.last' arguments. * [r1975] Add private function 'checkReverseDependencies'. 2015-04-23 warnes * [r1950] Update NEWS and ChangeLog * [r1949] - The 'q' argument to quantcut()'s 'q' now accept an integer indicating the number of equally spaced quantile groups to create. (Suggestion and patch submitted by Ryan C. Thompson.) * [r1946] Revers accidental text deletion: * [r1945] Update for gtools 3.4.3 * [r1944] Remove debugging code and stray browser() call 2015-04-14 warnes * [r1923] Fix typo 2015-04-09 warnes * [r1921] Update gtools ChangeLog * [r1920] Move first()/last()/left()/right() to gdata. Add new functions na.replace() and loadedPackages(). Add more text to package description. 2015-04-08 warnes * [r1919] Move first/last/left/right to from gtools to gdata 2015-04-06 warnes * [r1918] Correct URL * [r1917] Update NEWS and ChangeLog for gtools 3.5.0 * [r1916] Add ChangeLog files to repository * [r1915] Implement fix to keywords() needed for R-3.4.1, as suggested by Kurt Hornik. * [r1914] - Export S3 methods for first(), last(), left() and right(). - Ensure code matches man page for first(), last(), left(), and right(). 2014-10-09 warnes * [r1897] Update for 3.5.0 release of gtools * [r1896] Make right() and left() S3 methods for classes data.frame and matrix 2014-08-27 warnes * [r1872] Fix man page * [r1871] Finish adding first(), last(), left(), and right(). * [r1870] Add functions first(), last(), left(), and right(). 2014-05-28 warnes * [r1816] Update for gtools 3.4.1 * [r1815] Add test to ensure smartbind() properly handles Date columns. * [r1814] smartbind: Convert non-native type columns (except factor) to character. 2014-04-18 arnima * [r1813] Main arg is 'x' like showNonASCII(x), preformatted notes instead of verb 2014-04-17 warnes * [r1810] Update ASCIIfy man page to match source code and add keywords * [r1809] Update NEWS for gtools 3.4.0 * [r1808] Add ASCIIfy function posted to RDevel by Arni Magnusson 2014-03-01 warnes * [r1776] Fix cut-and-paste error. * [r1775] Update files for gtools 3.3.1 release * [r1774] Fix bug in gtools::mixedorder regular expression for regognizing numbers. (Periods weren't escaped). 2014-02-11 warnes * [r1773] Create and use locate copy of tools:::.split_op_version. * [r1772] Update for gtools 3.3.0. * [r1771] Fix arguments * [r1770] Update arguments to match code. * [r1769] Add getDependencies() function to return a list of package dependencies. 2014-01-14 warnes * [r1768] Update for bug-fix release * [r1767] Add test file for binsearch() function. * [r1766] Fixed bug where binsearch() returned the wrong endpoint & value when the found value was at the upper endpoint. 2014-01-13 warnes * [r1765] Fix typo 2014-01-11 warnes * [r1764] Update for gtools release 3.2.0 * [r1763] fixes for R CMD check * [r1762] Fixes for gtools release 3.2.0 2013-12-23 warnes * [r1761] Extend the keywords() function to return keywords associated with a specified topic via 'keywords(topic)'. * [r1760] Add keyword. * [r1759] Add stars.pval() function to convert p-values into significance symbols. 2013-11-26 warnes * [r1748] 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] Use ".Deprecated" instead of warning. 2013-11-06 warnes * [r1746] Update files for gtools 3.1.1 * [r1745] Fix problem with mixedorder/mixedsort when there is only zero or one elements in the vector. 2013-09-23 warnes * [r1716] Comment out empty sections in gtools-deprecated.Rd * [r1715] Update files for gtools 3.1.0 release * [r1714] Make 'addLast()' defunct. * [r1713] Mark 'addLast()' as defunct and move 'lastAdd()' function to a separate file. * [r1712] Update for gtools 3.0.1 release * [r1711] Use 'suppressWarnings() instead of 'options(warn=-1)' in 'mixedorder()'. 2013-07-07 warnes * [r1705] Fix typo. 2013-07-06 warnes * [r1704] Fix Rd warning. * [r1703] Include lastAdd in NAMESPACE * [r1702] Change assert from deprecated to defunct. * [r1701] Improve deprecation message * [r1700] Update for gtools 3.0.0 * [r1699] Create new function lastAdd to replace addLast and mark addLast as deprecated. 2013-07-05 warnes * [r1698] Point out that addLast() modifies the value of .Last in the global environment. * [r1697] Point out that addLast() modifies the value of .Last in the global environment. * [r1696] Update for gtools 2.7.2 mark 2 * [r1695] Remove cross-reference to (obsolete?) moc package * [r1694] Update for gtools 2.7.2 * [r1693] Update for R version 3.0.0 and later 2013-03-17 warnes * [r1640] 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] Update for gtools 2.7.0. * [r1569] Document new 'verbose' argument to smartbind(). * [r1568] Clean up R CMD check warnings. 2012-05-04 warnes * [r1529] smartbind(): Improve handling of factors and ordered factors. 2011-10-05 warnes * [r1518] Update version number for release * [r1517] Add 'sep' argument to smartbind() to allow specification of character used to separate components of constructed names 2011-09-28 warnes * [r1513] smartbind(): Prevent coersion to data frame from mangling column names. * [r1512] Add 'fill' argument to smartbind() to specify a value to use for missing entries. * [r1511] Add 'fill' argument to smartbind() to specify a value to use for missing entries. 2010-08-14 warnes * [r1451] 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] Update version number for new release * [r1433] Change Greg's email address to greg@warnes.net * [r1432] Fix error in checkRVersion() 2010-04-28 ggrothendieck2 * [r1431] fixed problems with R CMD CHECK 2009-05-09 warnes * [r1328] Escape $ in .Rd file to avoid latex issues * [r1327] Update NEWS and create softlinks for NEWS and ChangeLog in top level directory * [r1326] Move actual NEWS file into inst. * [r1325] Update Greg's email address and fix Rd syntax errors 2009-02-16 warnes * [r1313] Correct windows make flags as suggested by Brian Ripley. 2008-08-15 warnes * [r1303] Add keywords() function to show /doc/KEYWORDS file 2008-05-29 warnes * [r1285] Add newVersionAvailable() function to compare running and latest available R versions 2008-05-26 warnes * [r1284] Update license specification * [r1283] Remove 'assert' man page 2008-05-22 warnes * [r1282] Finish rename of assert.R to assert-depricated.Rd * [r1281] Add checkRVersion.R file * [r1280] Rename again to get correct extension! * [r1279] Update NEWS for 2.5.0 * [r1278] Add man page for checkRVersion * [r1277] Rename assert-deprecated.R to assert.R to meet R file name requirements. * [r1276] Add checkRVersion to NAMESPACE, and increment version in DESCRIPTION. * [r1275] Remove broken SEE LSO reference 2008-04-12 warnes * [r1259] Improve text explanation of how defmacro() and strmacro() differ from function(). * [r1258] assert() is now deprecated in favor of base::stopifnot() * [r1257] Rename 'assert.R' to 'deprecated.R'. * [r1256] Assert is now deprecated in favor of base::stopifnot(), so add call to .Deprecated() to inform the user. 2007-11-30 warnes * [r1228] Update defnitions of odd() and even() to use modulus operator instead of division. Prettier, I think, :-D 2007-08-08 warnes * [r1121] Fix bug identified by R-2.6's check routings in binsearch() * [r1120] Add the binsearch(), previously in the genetics package. 2007-07-18 ggorjan * [r1100] typo fixed 2007-04-12 warnes * [r1088] Add ask() function to prompt the user and collect a single response. 2007-04-07 warnes * [r1087] Fix improper escapes in regexp detected by R 2.5.0 package check. 2007-03-23 warnes * [r1083] Allow permutations for r>n provided repeats.allowed=TRUE 2006-11-28 warnes * [r1023] Replace F with FALSE in smartbind example. 2006-11-27 warnes * [r1022] Replace T with TRUE in smartbind example * [r1021] Temprary remove to reset binary flag * [r1020] Temprary remove to reset binary flag * [r1019] Add smartbind() to list of exported functions, and add corresponding documentation file. * [r1018] Update my email address 2006-11-14 ggorjan * [r1012] Removed executable property 2006-08-02 warnes * [r977] Update my email address 2006-05-05 nj7w * [r958] Fixed minor typo - in {value} - n was replaced by r * [r957] Fixed minor typos 2006-03-01 warnes * [r903] Add smartbind function 2006-01-18 warnes * [r845] Add concept tags to make mixedsort easier to locate. 2005-12-21 warnes * [r837] Update version number and date * [r836] Note changes for 2.2.3 * [r835] Should now work on Windows 2005-12-20 warnes * [r834] 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] Change C++ comment to standard comment 2005-12-13 nj7w * [r810] *** empty log message *** * [r809] Updated NEWS and removed ChangeLog 2005-12-12 nj7w * [r800] Updated version for CRAN release 2005-12-08 warnes * [r790] Add C source code for setTCPNoDelay. 2005-12-01 nj7w * [r776] Updated Greg's email address 2005-11-29 warnes * [r769] Add UseDynLib to NAMESPACE so the shared library gets properly loaded. * [r768] - Remove debugging comments - Change return value on success to "Success". 2005-11-22 warnes * [r758] NAMESPACE * [r757] Update news for 2.2.1 release. * [r756] Fixes for R CMD check * [r755] Add setTCPNoDelay() function and documentation * [r745] 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] More changes for strmacro(), also changes for 2.1.1 release * [r677] Add strmaco() which defines functions that use strings for macro definition 2005-09-21 warnes * [r676] Add support for DOTS/... arguments to defmacro 2005-09-12 nj7w * [r671] Updated Greg's email 2005-09-02 nj7w * [r653] Exported assert * [r652] Updated the version number * [r651] Added NEWS * [r650] Added ChangeLog * [r649] Fixed syntax errors 2005-09-02 warnes * [r648] Add assert() and documentation * [r647] Fix problem in defmacro.Rd file: don't use \code{} in the example section. 2005-08-31 warnes * [r645] 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] Add stand-alone DESCRIPTION file and remove old DESCRIPTION.in file. 2005-06-13 nj7w * [r626] Fixed a bug in mixedsort - check if "which.na" and "which.blank" is numeric(0) before subsetting the datasets. 2005-06-09 nj7w * [r625] Updating the version number, and various help files to synchronize splitting of gregmisc bundle in 4 individual components. 2005-05-10 warnes * [r619] 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] - 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] Move drop.levels() from gtools to gdata. * [r599] Minor reordering of functions in file * [r598] Move frameApply() to gdata package. * [r597] Fix error if only one value passed to mixedorder. * [r596] Add proper handling where more than one quantile obtains the same value 2005-04-01 warnes * [r595] Add CVS ID tag to file headers. * [r594] Fixes from Jim Rogers for R CMD check problems in frameApply 2005-03-31 warnes * [r591] Updates to drop.levels() and frameApply() from Jim Rogers * [r590] Add ELISA data set used by frameApply and drop.levels examples 2005-02-25 warnes * [r562] Replace 'T' with TRUE. * [r561] Remove dependency on ELISA data set for the example. * [r558] Add drop.levels, frameApply to namespace export. 2005-02-15 warnes * [r542] Add frameApply and drop.levels contributed by Jim Rogers. 2005-01-12 warnes * [r515] 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] Updated to pass R CMD check. 2004-09-03 warneg * [r446] initial bundle checkin 2004-09-02 warneg * [r442] Initial revision 2004-08-27 warnes * [r441] Fixed bug in mixedsort, and modified reorder.factor to use mixedsort. 2004-08-26 warnes * [r440] - 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] Nitin Jain added by= parameter to allow specifying separation between groups. 2004-05-26 warnes * [r345] Escape underscores in email addresses so Latex is happy. * [r343] Replace 'T' with 'TRUE' to pass R CMD check. 2004-05-25 warnes * [r334] Remove extraneous comments. * [r333] 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] Check if argument is a vector before doing is.na to avoid generating a warning. * [r322] Add invalid() function for testing if a parameter value is non-missing, non-NA, non-NULL. 2004-04-27 warnes * [r321] Replaced argument `as.list' with `simplify'. Updated documentation, and updated examples appropriately. 2004-04-26 warnes * [r320] Added as.list argument to return one list element per evaluation. 2004-03-26 warnes * [r303] Uncomment and fix large 'n' example. * [r301] - Update to match changes in running() - Add examples to illustrate new arguments. - Modify running correlation plot example to be more clear. * [r299] More of the same. * [r297] 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] - 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] - match function argument defaults with 'usage' 2003-11-21 warnes * [r237] Removed 'deqn' call that was confusing things. * [r234] Add email address to author field * [r233] - new files * [r232] - Change 'T' to 'TRUE' in mixedsort.R - Add missing brace in mixedsort.Rd 2003-11-20 warnes * [r230] - Move 'odd' and 'even' functions to a separate file & provide documentation 2003-11-18 warnes * [r227] - Renamed smartsort to mixedsort and added documentation. 2003-11-10 warnes * [r220] - Add files contributed by Arni Magnusson . As well as some of my own. 2003-05-23 warnes * [r196] - 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] - Fixed tpyo in example that allowed combinations(500,2) to run when it should have been ignred for testing.. 2003-04-10 warnes * [r186] - 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] - 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] Checkin for version 0.5.3 2002-03-26 warneg * [r97] Initial Checkin * [r96] Initial checkin. 2002-03-20 warneg * [r91] - Added definition of is.R function. - Added boxplot.formula 2002-03-07 warneg * [r90] - Added documentation and example for running2 * [r89] - Added "running2", which handles both univariate and bivariate cases - Modified "running" to call "running2" 2002-02-05 warneg * [r75] - Fix typo that caused code meant to run only under S-Plus to run under R, causing problems. 2001-12-19 warneg * [r67] - Added code for %in%. 2001-09-18 warneg * [r18] Release 0.3.2 2001-09-01 warneg * [r17] Initial checkin. * [r16] Release 0.3.0 2001-08-25 warneg * [r13] Initial CVS checkin. * [r11] Fixed a typo and a syntax error. * [r7] Initial Checkin 2001-06-29 warneg * [r6] Initial revision. gtools/tests/0000755000176000001440000000000012531372107012754 5ustar ripleyusersgtools/tests/test_mixedorder.R0000644000176000001440000000170412304437711016303 0ustar ripleyuserslibrary(gtools) ## Examples from man page Treatment <- c("Control", "Asprin 10mg/day", "Asprin 50mg/day", "Asprin 100mg/day", "Acetomycin 100mg/day", "Acetomycin 1000mg/day") stopifnot( mixedorder(Treatment)==c(5, 6, 2, 3, 4, 1) ) 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")) stopifnot( mixedorder(x)==c(7, 11, 4, 5, 3, 8, 2, 1, 6, 12, 18, 17, 16, 13, 15, 14, 10, 9) ) ## Bug reported by Aaron Taudt on 2014-03-01 tmp <- c("uniresult_simulated_H3k27ac_binsize_200_chr1.RData", "uniresult_simulated_H3k27me3_binsize_200_chr1.RData", "uniresult_simulated_H3k36me3_binsize_200_chr1.RData", "uniresult_simulated_H3k4me3_binsize_200_chr1.RData", "uniresult_simulated_H3k9me3_binsize_200_chr1.RData") stopifnot( mixedorder(tmp)==c(4, 5, 1, 2, 3) ) gtools/tests/smartbind_Dates.R0000644000176000001440000000041112341225536016200 0ustar ripleyuserslibrary(gtools) today <- Sys.Date() tenweeks <- seq(today, length.out=10, by="1 week") df1 <- data.frame(dates=tenweeks, chars=letters[1:10], ints=1:10, numeric=1.1:10.1) df2 <- data.frame(chars=letters[11:20], ints=11:20, numeric=11.1:20.1) smartbind(df1, df2) gtools/tests/test_ddirichlet.R0000644000176000001440000000063312530631000016240 0ustar ripleyusers## Regression test for bug reported by John Nolan: ## ## Whenever the pair (x[i], a[i]) == (0,1), NA would be returned, due ## to an internal computation of ( 0 * -Inf ) => NaN ## ## The code now checks for this particular issue and sets the value of ## ( 0 * -Inf ) to 0, which is correct for this calculation. ## library(gtools) x = c(0,0,1) alpha = c(1,2,3) stopifnot( ddirichlet(x=x, alpha=alpha) == 0 ) gtools/tests/test_binsearch.R0000644000176000001440000000315412265310754016103 0ustar ripleyuserslibrary(gtools) ############################## ### Examples from man page ### ############################## ### Toy examples # search for x=10 s <- binsearch( function(x) x-10, range=c(0,20) ) stopifnot(s$where==10) # search for x=10.1 s <- binsearch( function(x) x-10.1, range=c(0,20) ) stopifnot( s$where==c(10,11) ) ### 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 ) ) s = binsearch( fun, range=1:26 ) stopifnot( LETTERS[s$where]=="M") ################################## ### Test boundary contiditions ### ################################## s = binsearch(fun = function(x) x-10, range=c(1,10) ) with(s, stopifnot(where==10, value==0, flag=="Found") ) s = binsearch(fun = function(x) x-1, range=c(1,10) ) with(s, stopifnot(where==1, value==0, flag=="Found") ) checkWarning <- function( expr ) { myEnv <- environment() catchWarning <- function(w) { assign("warningValue", w, pos=myEnv) invokeRestart("muffleWarning") } retval <- withCallingHandlers(expr = expr, warning = catchWarning) if( !exists("warningValue", where=myEnv, inherits=FALSE) ) stop("Expected a warning message") } checkWarning( s <- binsearch(fun = function(x) x-10, range=c(1,9) ) ) with(s, stopifnot(where==9, value==-1, flag=="Upper Boundary" ) ) checkWarning( s <- binsearch(fun = function(x) x-1, range=c(2,10) ) ) with(s, stopifnot(where==2, value==1, flag=="Lower Boundary" ) ) gtools/src/0000755000176000001440000000000012531372107012401 5ustar ripleyusersgtools/src/roman2int.c0000644000176000001440000000206712531372226014465 0ustar ripleyusers#include void convert( char** letters, int* nchar, int* values ) { if(*nchar<1) return; for(int i=0; i<*nchar; i++) { if(letters[0][i]== 'I') values[i]=1; else if(letters[0][i]== 'V') values[i]=5; else if(letters[0][i]== 'X') values[i]=10; else if(letters[0][i]== 'L') values[i]=50; else if(letters[0][i]== 'C') values[i]=100; else if(letters[0][i]== 'D') values[i]=500; else if(letters[0][i]== 'M') values[i]=1000; else error("Invalid roman numeral '%c'", letters[0][i]); } } void roman2int(char** str, int* nchar, int* retval) { if (*nchar < 1) { *retval = NA_INTEGER; return; } int* values = (int*) R_alloc(*nchar, sizeof(int)); convert(str, nchar, values); int total=0; if (*nchar > 1) { for(int n=0; n<*nchar-1; n++) { if(values[n] #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.win0000644000176000001440000000002412531372226014667 0ustar ripleyusersPKG_LIBS = -lws2_32 gtools/NAMESPACE0000644000176000001440000000143112531225535013032 0ustar ripleyusersuseDynLib(gtools) export( addLast, asc, ASCIIfy, ask, assert, assignEdgewise, binsearch, capture, chr, checkRVersion, combinations, ddirichlet, defmacro, even, foldchange, foldchange2logratio, getDependencies, inv.logit, invalid, keywords, lastAdd, loadedPackages, logit, logratio2foldchange, mixedorder, mixedsort, na.replace, odd, permutations, permute, quantcut, rdirichlet, roman2int, running, scat, setTCPNoDelay, smartbind, sprint, stars.pval, strmacro, unByteCode, unByteCodeAssign ) gtools/NEWS0000644000176000001440000002003412531224511012303 0ustar ripleyusersgtools 3.5.0 - 2015-04-28 ------------------------- New Functions: - New roman2int() functon to convert roman numerals to integers without the range restriction of utils::as.roman(). - New asc() and chr() functions to convert between ASCII codes and characters. (Based on the 'Data Debrief' blog entry for 2011-03-09 at http://datadebrief.blogspot.com/2011/03/ascii-code-table-in-r.html). - New unByteCode() and unByteCodeAssign() functions to convert a byte-code functon to an interpeted code function. - New assignEdgewise() function for making assignments into locked environments. (Used by unByteCodeAssign().) Enhacements: - mixedsort() and mixedorder() now have arguments 'decreasing', 'na.last', and 'blank.last' arguments to control sort ordering. - mixedsort() and mixedirdeR() now support Roman numerals via the arguments 'numeric.type', and 'roman.case'. (Request by David Winsemius, suggested code changes by Henrik Bengtsson.) - speed up mixedorder() (and hence mixedsort()) by moving suppressWarnings() outside of lapply loops. (Suggestion by Henrik Bengtsson.) - The 'q' argument to quantcut() now accept an integer indicating the number of equally spaced quantile groups to create. (Suggestion and patch submitted by Ryan C. Thompson.) Bug fixes: - Removed stray browser() call in smartbind(). - ddirichlet(x, alpha) was incorrectly returning NA when for any i, x[i]=0 and alpha[i]=1. (Bug report by John Nolan.) Other changes: - Correct typographical errors in package description. gtools 3.4.2 - 2015-04-06 ------------------------- New features: - New function loadedPackages() to display name, version, and path of loaded packages (package namespaces). - New function: na.replace() to replace missing values within a vector with a specified value.` Bug fixes: - Modify keywords() to work properly in R 3.4.X and later. gtools 3.4.1 - 2014-05-27 ------------------------- Bug fixes: - smartbind() now converts all non-atomic type columns (except factor) to type character instead of generating an opaque error message. Other changes: - the argument to ASCIIfy() is now named 'x' instead of 'string'. - minor formatting changes to ASCIIfy() man page. gtools 3.4.0 - 2014-04-14 ------------------------- New features: - New ASCIIfy() function to converts character vectors to ASCII representation by escaping them as \x00 or \u0000 codes. Contributed by Arni Magnusson. gtools 3.3.1 - 2014-03-01 ------------------------- Bug fixes: - 'mixedorder' (and hence 'mixedsort') not properly handling single-character strings between numbers, so that '1a2' was being handled as a single string rather than being properly handled as c('1', 'a', '2'). gtools 3.3.0 - 2014-02-11 ------------------------- New features: - Add the getDependencies() function to return a list of dependencies for the specified package(s). Includes arguments to control whether these dependencies should be constructed using information from locally installed packages ('installed', default is TRUE), avilable CRAN packages ('available', default is TRUE) and whether to include base ('base', default=FALSE) and recommended ('recommended', default is FALSE) packages. Bug fixes: - binsearch() was returning the wrong endpoint & value when the found value was at the upper endpoint. gtools 3.2.1 - 2014-01-13 ------------------------- Bug fixes: - Resolve circular dependency with gdata gtools 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/0000755000176000001440000000000012531372107012523 5ustar ripleyusersgtools/data/ELISA.rda0000644000176000001440000000525412531372226014060 0ustar ripleyusersBZh91AY&SYR&UUU ^)*UUn@D=&Ȟ lCǦM62L4'd& &4M4TRTJzj Fj@F4da2FM44@4 C@@224 h M ?RM @hC@d@hd44 h !@ 4Ѡ*HhO ѣI '=(y'oS(h=L=FأF'چ66i=#MC QL&=WVX,E⼟z=9i ً#-RR03b1(ҙZ49LaGGWw8b ;uD45DnTFΏ$Yt:=Ғ*b(3˘gqk߈_r\kůvMIJ#+(b2F-طeX-6mBr[@0_Z L;& ͌dˆbyᡥaEѼK`#_K,&1$F>WA`urhWگS28ȇV|+ܷ.:onB6 mѣu`vUUTZֵkZֵkZֶ9)JPe"sx k2dɬªªªªªªªªªR)[*뮻mmUUUVHobŋTL*L*L*L*L*L*L*L*L*JWd,;/   #DuL*L*L*L*L""%TJU/\rׯ^ JUYJRJDDDJDDDJD*ªªªªªRRv۷UUUUUX"qÇ9TְDU]vL2dʪJUYJR9s} s9`LŊ۷/s 8iJ_ r"r魜sg'^z6uuʻjq/!uWRbI,Tl*9ECdh0$ q6wW,Ŧ,#М IlDc0FDq2%%0e_J:U&m F ]kž?8I 96dΊ)XS6FB : iJhޑ^N(>Ԡ=at/V#]TgbLO YƱrrS]VA(s@ʟὊ>r |:cTL([-Mi8ªÚ h tHR@- 0 k@1|tl\Ǯ26B5KȲ'^.3\ x^,rX,X vt.|(|Qx?IIwĞ?: ox331s|xwxb짷7>q석u|nH 9Bw= W ^ݎFΟ8,e_8A+U_?s: >fNI$|bw;Ms,; Ћl$[$w"M~DN_x#Bi^lM#!'\η%7MЉ5ٹLs.~qsոr?&GAI31 ˒$‘۳ĚO}'$8YFF &0dwutn ~2Ws,%^M^u|s/:(\tBev?[ts\#1^}ŰNu>_]ϷGQ;.^)Kmfcr+6=ϱ74KǾ ;cpۏ>*\xˮ&*ZL_m{4꼪xv}iq\6g8Uf]zwyYOL}f Įֻu=|jjfR=r}݋n|y}yo7*y9}3;\KdLTJPIeγV'Lp=ݸ{#DB{?mh7=ά=Q`juK2#G5ŋW}i;h-9k\\̰bYt[WmKJغ,U {OqWa}F\.:нc{#v3%5l _w$S ,Kgtools/R/0000755000176000001440000000000012531372107012013 5ustar ripleyusersgtools/R/loadedPackages.R0000644000176000001440000000111312511553321015016 0ustar ripleyusersloadedPackages <- function(silent=FALSE) { packageNames <- loadedNamespaces() packageVersions <- sapply(packageNames, function(package) paste(packageVersion(package), sep=".") ) packagePaths <- find.package(packageNames) inSearchPath <- match(packageNames, gsub('^package:', '', grep('^package:', search(), value=TRUE))) retval <- data.frame(Name=packageNames, Version=packageVersions, Path=packagePaths, SearchPath=inSearchPath) retval$SearchPath <- na.replace(retval$SearchPath, '-') retval <- retval[order(inSearchPath),] if(!silent) print(retval) retval } gtools/R/logit.R0000644000176000001440000000050310252050056013244 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/unByteCode.R0000644000176000001440000000150712517604670014211 0ustar ripleyusers## Convert a byte-compiled function to an interpreted-code function unByteCode <- function(fun) { FUN <- eval(parse(text=deparse(fun))) environment(FUN) <- environment(fun) FUN } ## Replace function definition inside of a locked environment **HACK** assignEdgewise <- function(name, env, value) { unlockBinding(name, env=env) assign( name, envir=env, value=value) lockBinding(name, env=env) invisible(value) } ## Replace byte-compiled function in a locked environment with an ## interpreted-code function unByteCodeAssign <- function(fun) { name <- gsub('^.*::+','', deparse(substitute(fun))) FUN <- unByteCode(fun) retval <- assignEdgewise(name=name, env=environment(FUN), value=FUN ) invisible(retval) } gtools/R/mixedsort.R0000644000176000001440000001116612531217743014165 0ustar ripleyusersmixedsort <- function(x, decreasing=FALSE, na.last=TRUE, blank.last=FALSE, numeric.type=c("decimal", "roman"), roman.case=c("upper","lower","both") ) { ord <- mixedorder(x, decreasing=decreasing, na.last=na.last, blank.last=blank.last, numeric.type=numeric.type, roman.case=roman.case ) x[ord] } mixedorder <- function(x, decreasing=FALSE, na.last=TRUE, blank.last=FALSE, numeric.type=c("decimal", "roman"), roman.case=c("upper","lower","both") ) { # - Split each each character string into an vector of strings and # numbers # - Separately rank numbers and strings # - Combine orders so that strings follow numbers numeric.type <- match.arg(numeric.type) roman.case <- match.arg(roman.case) if(length(x)<1) return(NULL) else if(length(x)==1) return(1) if( !is.character(x) ) return( order(x, decreasing=decreasing, na.last=na.last) ) delim="\\$\\@\\$" if(numeric.type=="decimal") { regex <- "((?:(?i)(?:[-+]?)(?:(?=[.]?[0123456789])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[eE])(?:(?:[-+]?)(?:[0123456789]+))|)))" # uses PERL syntax numeric <- function(x) as.numeric(x) } else if (numeric.type=="roman") { regex <- switch(roman.case, "both" = "([IVXCLDMivxcldm]+)", "upper" = "([IVXCLDM]+)", "lower" = "([ivxcldm]+)" ) numeric <- function(x) roman2int(x) } else stop("Unknown value for numeric.type: ", numeric.type) nonnumeric <- function(x) { ifelse(is.na(numeric(x)), toupper(x), NA) } x <- as.character(x) which.nas <- which(is.na(x)) which.blanks <- which(x=="") #### # - 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(regex, paste(delim,"\\1",delim,sep=""), x, perl=TRUE) # separate out numbers step1 <- strsplit(delimited, delim) # remove empty elements step1 <- lapply( step1, function(x) x[x>""] ) # create numeric version of data suppressWarnings( step1.numeric <- lapply( step1, numeric ) ) # create non-numeric version of data suppressWarnings( 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) if(is.na(na.last)) order.frame[which.nas,] <- NA else if(na.last) order.frame[which.nas,] <- Inf else order.frame[which.nas,] <- -Inf if(length(which.blanks) > 0) if(is.na(blank.last)) order.frame[which.blanks,] <- NA else if(blank.last) order.frame[which.blanks,] <- 1e99 else order.frame[which.blanks,] <- -1e99 order.frame <- as.list(order.frame) order.frame$decreasing <- decreasing order.frame$na.last <- NA retval <- do.call("order", order.frame) return(retval) } gtools/R/asc.R0000644000176000001440000000027112531225470012704 0ustar ripleyusersasc <- function(char, simplify=TRUE) sapply(char, function(x) strtoi(charToRaw(x),16L), simplify=simplify ) chr <- function(ascii) sapply(ascii, function(x) rawToChar(as.raw(x)) ) gtools/R/binsearch.R0000644000176000001440000000647312265257071014114 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=hi retval$value=val.hi } else { retval$flag="Between Elements" retval$where=c(lo, hi) retval$value=c(val.lo, val.hi) } return(retval) } gtools/R/ASCIIfy.R0000644000176000001440000000270412324265310013325 0ustar ripleyusersASCIIfy <- function(x, bytes=2, fallback="?") { bytes <- match.arg(as.character(bytes), 1:2) convert <- function(char) # convert to ASCII, e.g. "z", "\xfe", or "\u00fe" { raw <- charToRaw(char) if(length(raw)==1 && raw<=127) # 7-bit ascii <- char else if(length(raw)==1 && bytes==1) # 8-bit to \x00 ascii <- paste0("\\x", raw) else if(length(raw)==1 && bytes==2) # 8-bit to \u0000 ascii <- paste0("\\u", chartr(" ","0",formatC(as.character(raw),width=4))) else if(length(raw)==2 && bytes==1) # 16-bit to \x00, if possible if(utf8ToInt(char) <= 255) ascii <- paste0("\\x", format.hexmode(utf8ToInt(char))) else { ascii <- fallback; warning(char, " could not be converted to 1 byte")} else if(length(raw)==2 && bytes==2) # UTF-8 to \u0000 ascii <- paste0("\\u", format.hexmode(utf8ToInt(char),width=4)) else { ascii <- fallback warning(char, " could not be converted to ", bytes, " byte")} return(ascii) } if(length(x) > 1) { sapply(x, ASCIIfy, bytes=bytes, fallback=fallback, USE.NAMES=FALSE) } else { input <- unlist(strsplit(x,"")) # "c" "a" "f" "<\'e>" output <- character(length(input)) # "" "" "" "" for(i in seq_along(input)) output[i] <- convert(input[i]) # "c" "a" "f" "\\u00e9" output <- paste(output, collapse="") # "caf\\u00e9" return(output) } } gtools/R/oddeven.R0000644000176000001440000000022010724050367013557 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.R0000644000176000001440000000300010314564453013713 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/roman2int.R0000644000176000001440000000217612531371175014061 0ustar ripleyuserstestConvert <- function() { roman <- 'IVXLCDM' retval <- romandigit.convert(roman) stopifnot(retval==c(1,5,10,50,100,500,1000)) return(TRUE) } romandigit.convert <- function(roman) { retval <- .C('convert', roman=as.character(roman), nchar=as.integer(nchar(roman)), values=integer(nchar(roman)) ) retval$values } roman2int.inner <- function(roman) { results <- .C("roman2int", roman = as.character(roman), nchar = as.integer(nchar(roman)), value = integer(1), PACKAGE="gtools") return(results$value) } roman2int <- function(roman) { roman <- trimws(toupper(as.character(roman))) tryIt <- function(x) { retval <- try(roman2int.inner(x), silent=TRUE) if(is.numeric(retval)) retval else NA } retval <- sapply(roman, tryIt) retval } gtools/R/quantcut.R0000644000176000001440000000540112516264204014003 0ustar ripleyusers# $Id: quantcut.R 1949 2015-04-23 21:47:48Z warnes $ quantcut <- function(x, q=4, na.rm=TRUE, ... ) { if(length(q)==1) q <- seq(0,1, length.out=q+1) 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/checkReverseDependencies.R0000644000176000001440000000134012517604670017063 0ustar ripleyuserspackagefile="gdata_2.16.0.tar.gz" destdir=tempdir() checkReverseDependencies <- function(packagefile, destdir=tempdir(), cleanup=FALSE ) { if(!file.exists(packagefile)) stop(packagefile, " does not exist!") cat("Using directory '", destdir, "'. Remember to delete it when done.\n", sep='') file.copy(packagefile, destdir) package <- gsub("_.*$", "", packagefile) rdeps <- tools::package_dependencies(package, db=available.packages(), reverse = TRUE)[[1]] cat( length(rdeps), "reverse dependencies:\n") print(rdeps) tools::check_packages_in_dir(destdir, reverse=list(), Ncpus=6) if(cleanup) unlink(destdir, recursive=TRUE, force=TRUE) } gtools/R/combinations.R0000644000176000001440000000556610601055114014627 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/na.replace.R0000644000176000001440000000010412511553321014136 0ustar ripleyusersna.replace <- function(x, replace) { x[is.na(x)] <- replace x } gtools/R/keywords.R0000644000176000001440000000206712531371175014016 0ustar ripleyuserskeywords <- function( topic ) { file <- file.path(R.home("doc"),"KEYWORDS") if(missing(topic)) { file.show(file) } else { kw <- scan(file=file, what=character(), sep="\n", quiet=TRUE) kw <- grep("&", kw, value=TRUE) kw <- gsub("&[^&]*$","", kw) kw <- gsub("&+"," ", kw) kw <- na.omit(trimws(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) { matches <- help.search(keyword=k)$matches matches[ , match("topic", tolower(colnames(matches)))] } matches <- lapply(kw, topics) names(matches) <- kw tmp <- unlist(lapply( matches, function(m) grep(item, m, value=TRUE) )) names(tmp) } } gtools/R/dirichlet.R0000644000176000001440000000370312530175551014113 0ustar ripleyusers# $Id: dirichlet.R 2020 2015-05-23 22:12:57Z warnes $ # 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 <-(alpha-1)*log(x) s <- ifelse(alpha==1 & x==0, -Inf, s) 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.R0000644000176000001440000000022012166126122014226 0ustar ripleyusers## useful function, raises an error if the FLAG expression is FALSE assert <- function( FLAG ) .Defunct(new="stopifnot", package="gtools") gtools/R/lastAdd.R0000644000176000001440000000063512220057126013512 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.R0000644000176000001440000000044210252050056013556 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.R0000644000176000001440000001427512516257313014136 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[1] ## Coerce everything that isn't a native type to character if(! (newclass %in% c("logical", "integer", "numeric", "complex", "character", "raw") )) { newclass <- "character" warning("Converting non-atomic type column '", col, "' to type character.") } retval[[col]] <- as.vector(rep(fill,nrows), mode=newclass) } mode <- class(retval[[col]]) if(mode=="character") vals <- as.character(block[,col]) else vals <- block[,col] retval[[col]][start:end] <- as.vector(vals, mode=mode) } 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 { 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.R0000644000176000001440000000322212516257313013773 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]] } } 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 args <- match.call(expand.dots=TRUE)[-1] for(item in names(args)) reptab[[item]] <- args[[item]] ## 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) } 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/trimws.R0000644000176000001440000000056112531371415013466 0ustar ripleyusers## trimws was added in R 2.3.0. If we're using a previous version of ## R we need to define it. if(!exists('trimws', mode='function')) trimws <- function(s) { s <- sub(pattern="^[[:blank:]]+", replacement="", x=s) s <- sub(pattern="[[:blank:]]+$", replacement="", x=s) s } gtools/R/running.R0000644000176000001440000000460111770102444013616 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.R0000644000176000001440000000023412220057126013505 0ustar ripleyusersaddLast <- function( fun ) .Defunct(new=paste(".Last <- lastAdd(", deparse(substitute(fun)), ")", sep=''), package='gtools' ) gtools/R/newVersionAvailable.R0000644000176000001440000000144311017634744016106 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.R0000644000176000001440000000125010343152560014550 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.R0000644000176000001440000000100710252050056014220 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.R0000644000176000001440000000023212264351244013565 0ustar ripleyuserscapture <- function( expression, collapse="\n") .Defunct("capture.output", "base") sprint <- function(x,...) .Defunct("capture.output", "base") gtools/R/getDependencies.R0000644000176000001440000000665712276455140015247 0ustar ripleyusers## This function determines the dependencies for the specified ## package, exluding only packages found in "base". getDependencies <- function (pkgs, dependencies = c("Depends", "Imports", "LinkingTo"), installed=TRUE, available=TRUE, base=FALSE, recommended=FALSE) { pkgs.in = pkgs if (is.null(dependencies)) return(unique(pkgs)) dep2 <- c("Depends", "Imports", "LinkingTo") if(installed && !available) all.packages <- installed.packages() else if (available && !installed) all.packages <- available.packages() else all.packages <- as.matrix(smartbind(## installed.packages(), available.packages() )) rownames(all.packages) <- all.packages[,"Package"] p0 <- unique(pkgs) miss <- !p0 %in% row.names(all.packages) if (sum(miss)) { warning(sprintf(ngettext(sum(miss), "package %s is not available (for %s)", "packages %s are not available (for %s)"), paste(sQuote(p0[miss]), collapse = ", "), sub(" *\\(.*", "", R.version.string)), domain = NA, call. = FALSE) if (sum(miss) == 1L && !is.na(w <- match(tolower(p0[miss]), tolower(row.names(all.packages))))) { warning(sprintf("Perhaps you meant %s ?", sQuote(row.names(all.packages)[w])), call. = FALSE, domain = NA) } flush.console() } ## Whether to exclude base and recommended packages if(!base || !recommended) { priority <- NULL if(!base) priority <- c("base", priority) if(!recommended) priority <- c("recommended", priority) installed <- installed.packages(priority=priority) } else installed <- installed.packages()[FALSE,] p0 <- p0[!miss] p1 <- p0 not_avail <- character() repeat { deps <- apply(all.packages[p1, dependencies, drop = FALSE], 1L, function(x) paste(x[!is.na(x)], collapse = ", ")) res <- .clean_up_dependencies2( deps, installed=installed, all.packages) not_avail <- c(not_avail, res[[2L]]) deps <- unique(res[[1L]]) deps <- deps[!deps %in% c("R", pkgs)] if (!length(deps)) break pkgs <- c(deps, pkgs) p1 <- deps if (!is.null(dep2)) { dependencies <- dep2 dep2 <- NULL } } if (length(not_avail)) { not_avail <- unique(not_avail) warning(sprintf(ngettext(length(not_avail), "dependency %s is not available", "dependencies %s are not available"), paste(sQuote(not_avail), collapse = ", ")), domain = NA, call. = FALSE, immediate. = TRUE) flush.console() } pkgs <- unique(pkgs) pkgs <- pkgs[pkgs %in% row.names(all.packages)] p0 <- pkgs p0[ ! p0 %in% pkgs.in ] } gtools/R/RSCompat.S0000644000176000001440000001227310252050056013626 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.R0000644000176000001440000000020110607520671012710 0ustar ripleyusersask <- function(msg="Press to continue: ") { cat(msg); readLines(con=stdin(),n=1) } gtools/R/stars.pval.R0000644000176000001440000000040512256057363014242 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.R0000644000176000001440000000016410252050056013612 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.R0000644000176000001440000000052610252050056013065 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/clean_up_dependencies2.R0000644000176000001440000000557712276460544016543 0ustar ripleyusers.clean_up_dependencies2 <- function (x, installed, available) { .split_op_version <- function (x) { pat <- "^([^\\([:space:]]+)[[:space:]]*\\(([^\\)]+)\\).*" x1 <- sub(pat, "\\1", x) x2 <- sub(pat, "\\2", x) if (x2 != x1) { pat <- "[[:space:]]*([[<>=!]+)[[:space:]]+(.*)" version <- sub(pat, "\\2", x2) if (!grepl("^r", version)) version <- package_version(version) list(name = x1, op = sub(pat, "\\1", x2), version = version) } else list(name = x1) } .split_dependencies <- function(x) { .split2 <- function(x) { x <- sub("[[:space:]]+$", "", x) x <- unique(sub("^[[:space:]]*(.*)", "\\1", x)) names(x) <- sub("^([[:alnum:].]+).*$", "\\1", x) x <- x[names(x) != "R"] x <- x[nzchar(x)] x <- x[!duplicated(names(x))] lapply(x, .split_op_version) } if (!any(nzchar(x))) return(list()) unlist(lapply(strsplit(x, ","), .split2), FALSE, FALSE) } x <- x[!is.na(x)] if (!length(x)) return(list(character(), character())) xx <- .split_dependencies(x) if (!length(xx)) return(list(character(), character())) pkgs <- installed[, "Package"] have <- sapply(xx, function(x) { if (length(x) == 3L) { if (!x[[1L]] %in% pkgs) return(FALSE) if (x[[2L]] != ">=") return(TRUE) current <- as.package_version(installed[pkgs == x[[1L]], "Version"]) target <- as.package_version(x[[3L]]) eval(parse(text = paste("any(current", x$op, "target)"))) } else x[[1L]] %in% pkgs }) xx <- xx[!have] if (!length(xx)) return(list(character(), character())) pkgs <- row.names(available) canget <- miss <- character() for (i in seq_along(xx)) { x <- xx[[i]] if (length(x) == 3L) { if (!x[[1L]] %in% pkgs) { miss <- c(miss, x[[1L]]) next } if (x[[2L]] != ">=") { canget <- c(canget, x[[1L]]) next } current <- as.package_version(available[pkgs == x[[1L]], "Version"]) target <- as.package_version(x[[3L]]) res <- eval(parse(text = paste("any(current", x$op, "target)"))) if (res) canget <- c(canget, x[[1L]]) else miss <- c(miss, paste0(x[[1L]], " (>= ", x[[3L]], ")")) } else if (x[[1L]] %in% pkgs) canget <- c(canget, x[[1L]]) else miss <- c(miss, x[[1L]]) } list(canget, miss) } gtools/R/checkRVersion.R0000644000176000001440000000172312165601143014704 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/MD50000644000176000001440000000761212532022430012120 0ustar ripleyusers4b0aeb3913d411a5e1e6127d40dd770d *ChangeLog bc9c4bf090a979e97a42a514cced2b0b *DESCRIPTION d4beab1e34afb8dc3c154213bdbd7fe7 *NAMESPACE b92b360a7ff045e56efb600e1b5d3932 *NEWS 40be776640196133aebff67618b08dec *R/ASCIIfy.R 9eb418fd95aa09ba85aed159545dea61 *R/RSCompat.S a86a74ba04089ad58ea22e3a994a9b14 *R/addLast.R c6b3619410daf7b88dfc6e852fe1c322 *R/asc.R c4ae0d6b5867f6751981e9f93cd2f619 *R/ask.R 7e3c03026275ec8e336c73314cb73a69 *R/binsearch.R c70220a92fd3c5781638e3779cbd55ff *R/checkRVersion.R b1dfaaaf624c59b2ee5eeb680a412be7 *R/checkReverseDependencies.R 421b9d08ece06f33c20d21ad62ad768b *R/clean_up_dependencies2.R 529f69b81b6b734a4f637d250b5b71f9 *R/combinations.R 1c333b16a59dcaf7ccf20151962b6375 *R/defmacro.R 28d70252e7e25f8e3743fc07434acba9 *R/defunct.R 344b58e1976792a3295238c17df7e917 *R/deprecated.R e5149cd525adc83044c3a3eed1d432bf *R/dirichlet.R 1da2198e1d194c705ca89381159b7b63 *R/foldchange.R e759eb4772cb9ce930a0c570279155b3 *R/getDependencies.R 71212f4c14003458fc3e30638f339629 *R/invalid.R d7058406d6e00cdae229c8ee030df465 *R/keywords.R f00dfc3263a5854151f244493b3f04d0 *R/lastAdd.R 66f7bacaa290264693ee1b4cbe4cadc8 *R/loadedPackages.R 2bb525e1930ec3ba2afefa2ff43d74e0 *R/logit.R a93b94a3690a900de1eb5145194a34f2 *R/mixedsort.R 429ab819b15f97c8dd6e62db278336d9 *R/na.replace.R 93a46a6ef5937bdd112468daceac00a6 *R/newVersionAvailable.R 07cd779ab7e64f697604b8b4fa4c9d70 *R/oddeven.R 1d016a924dd59daa78ea62d986da2929 *R/permute.R d01a487fce38a8d7ecd8949767c56f81 *R/quantcut.R 5a3ee0e3dfa4eb4cae1737af02cf8c6f *R/roman2int.R 02390191f23321a34fcfc41719d66dc6 *R/running.R a5ea32bab219fd7c634f034dddada96b *R/scat.R e5ddc84d8a502feed32f7f6b1b5e25ab *R/setTCPNoDelay.R 9633d96613b34ba3539dc2f9cb038af3 *R/smartbind.R ef22fb4007dec9fb62eb5ed947292fa3 *R/stars.pval.R bbc04a8581924855fb4107a90811fa52 *R/strmacro.R e302b31547caf90872346ee1f0867e1f *R/trimws.R 8e36d638d9b5c0c03d6f78235d07df96 *R/unByteCode.R acc7c743e7b54a541d54b8c7af52043e *data/ELISA.rda 4b0aeb3913d411a5e1e6127d40dd770d *inst/ChangeLog b92b360a7ff045e56efb600e1b5d3932 *inst/NEWS e45b4855b4a81e953876cbec7cd1b588 *man/ASCIIfy.Rd 904304f52b08ec847904ac2aa5be9aef *man/ELISA.Rd b2eac3f299f642616aa71dc03f1352f0 *man/asc.Rd c5b7124f5fdbcc83f2e283314df95858 *man/ask.Rd ecbe8481bdcff0d8abd1a47cc64ca7b2 *man/binsearch.Rd e1a3f01f01db3e883397eaa49037af6f *man/checkRVersion.Rd 0b2fba4b1456254689640add6afec843 *man/combinations.Rd 1c240ef01582dd99e3a2e432e7dfb2ba *man/defmacro.Rd 3ac18878a63f7ca4913f66d5ecb72a4a *man/dirichlet.Rd 74868a3948263db0fbc2519b792acba2 *man/foldchange.Rd c208ca0a5e9c38fcb903cfd7656d5375 *man/getDependencies.Rd aa98190531ff93721b715e61000f76a4 *man/gtools-defunct.Rd 72d1da64e38796cc37347aa1be02bdd2 *man/gtools-deprecated.Rd 01c743eee2dbb9dc14d02035fa05063c *man/invalid.Rd 8d8b5429047edd4ed52f8f8f6b11f807 *man/keywords.Rd 67b9c146bd8470b1dd5ddcac782c2071 *man/lastAdd.Rd 8ab31f5f313c145e05601fd8afc7b59b *man/loadedPackages.Rd 3c207d731ad8ead62af138afe2e20c5f *man/logit.Rd 74e953706b708ad96dfde10268feaafa *man/mixedsort.Rd 8d5842217510c21d95fb697caee3e6c6 *man/na.replace.Rd f4d6f8222b9448ef039d9cbf582ee29e *man/oddeven.Rd f911c6c34412df66c1ff0d6376f46c3f *man/permute.Rd f417491b0b09a309c23f27f97af4dd5f *man/quantcut.Rd 90873b9cb32a59aaaf62cbc5b302e82b *man/roman2int.Rd 20033253beddc01faf5829cdf43f01fb *man/running.Rd f781e22f646cf803a7f24129525521fc *man/scat.Rd 5dae46a9758c2a81d25d87881f7b42ee *man/setTCPNoDelay.Rd ece07b78ccb279ab1f88a836c6a0378d *man/smartbind.Rd 7ba286fa2b1bc994de1c6ec78883cdc8 *man/stars.pval.Rd b726be2eb3bedb0e2f6a4d4e878eef8d *man/unByteCode.Rd 8d4158b8eb92153e2d3f581682b2a3c1 *src/Makevars.win ca5f00b573fc8591602b6378746e2eee *src/roman2int.c bb28a3858ac5a6152565d3b8cef8c70c *src/setTCPNoDelay.c 6c36d5eac8884ab13c200c1113cf9236 *tests/smartbind_Dates.R b859dff6a12425f4ba692dc7706e99ed *tests/test_binsearch.R b4b7e4ed52ac89a56e2125620e524c4a *tests/test_ddirichlet.R 33c5986481c62f046106b02abc4d0c74 *tests/test_mixedorder.R gtools/DESCRIPTION0000644000176000001440000000361412532022430013314 0ustar ripleyusersPackage: gtools Title: Various R Programming Tools Description: Functions to assist in R programming, including: - assist in developing, updating, and maintaining R and R packages ('ask', 'checkRVersion', 'getDependencies', 'keywords', 'scat'), - calculate the logit and inverse logit transformations ('logit', 'inv.logit'), - test if a value is missing, empty or contains only NA and NULL values ('invalid'), - manipulate R's .Last function ('addLast'), - define macros ('defmacro'), - detect odd and even integers ('odd', 'even'), - convert strings containing non-ASCII characters (like single quotes) to plain ASCII ('ASCIIfy'), - perform a binary search ('binsearch'), - sort strings containing both numeric and character components ('mixedsort'), - create a factor variable from the quantiles of a continuous variable ('quantcut'), - enumerate permutations and combinations ('combinations', 'permutation'), - calculate and convert between fold-change and log-ratio ('foldchange', 'logratio2foldchange', 'foldchange2logratio'), - calculate probabilities and generate random numbers from Dirichlet distributions ('rdirichlet', 'ddirichlet'), - apply a function over adjacent subsets of a vector ('running'), - modify the TCP\_NODELAY ('de-Nagle') flag for socket objects, - efficient 'rbind' of data frames, even if the column names don't match ('smartbind'), - generate significance stars from p-values ('stars.pval'), - convert characters to/from ASCII codes. Version: 3.5.0 Date: 2015-05-26 Author: Gregory R. Warnes, Ben Bolker, and Thomas Lumley Maintainer: Gregory R. Warnes License: GPL-2 Repository: CRAN Repository/R-Forge/Project: r-gregmisc Repository/R-Forge/Revision: 2048 Repository/R-Forge/DateTimeStamp: 2015-05-27 16:38:37 Date/Publication: 2015-05-29 10:36:40 NeedsCompilation: yes Packaged: 2015-05-27 16:45:10 UTC; rforge Depends: R (>= 2.10) gtools/ChangeLog0000644000176000001440000005311112531224511013360 0ustar ripleyusers2015-05-27 warnes * [r2039] R/mixedsort.R, man/mixedsort.Rd: Add roman numeral support to mixedorder() and mixedsort(). * [r2037] man/asc.Rd: Add asc() and chr() functions for converting between characters and ASCII codes * [r2036] R/roman2int.R: roman2int() now returns NA for invalid roman numeral strings instead of generating an error. * [r2035] NAMESPACE: Add asc(), chr(), assignEdgewise(), unByteCode(), and unByteCodeAssign() to package NAMESPACE. * [r2034] R/asc.R: Add asc() and chr() functions for converting between characters and ASCII codes 2015-05-26 warnes * [r2030] inst/ChangeLog: Add changelog to svn repository 2015-05-25 warnes * [r2029] tests/test_ddirichlet.R: Add library call. * [r2028] man/unByteCode.Rd: Fix typo and add documentation for argument 'name'. * [r2027] man/mixedsort.Rd: Fix typo. * [r2026] man/mixedsort.Rd: Add description of blanklast argument, fix typo. * [r2025] man/quantcut.Rd: Change usage to match actual definition. * [r2024] man/mixedsort.Rd: Note characters sorting ignores case. * [r2023] man/mixedsort.Rd: Remove '...' from arglist to match source code. * [r2022] man/mixedsort.Rd: Replace unicode quotes with \code{..}. 2015-05-23 warnes * [r2021] tests/test_ddirichlet.R: Add regression test ddirichlet() bug for x[i]=0, alpha[i]=1: ddirichlet(x, alpha) was returning NA rather than 0. * [r2020] R/dirichlet.R: ddirichlet() was incorrectly returning NA when x[i]=0 and alpha[i]=1. In this case, the one calculation became (-Inf * 0), which R evaluates to NaN. The correction is to detect this case and substitute -Inf instead of NaN. 2015-05-08 warnes * [r2019] R/mixedsort.R: Summary: Speed up mixedorder by moving suppressWarnings outside of lapply loops. (Suggestion by Henrik Bengtsson.) 2015-05-02 warnes * [r2018] Rename 'trunk' to 'pkg' for compatibility with R-forge * [r2017] Minor layout change. * [r2016] Remove stray 'svn' that was inserted into the code. * [r2015] Add man page for unByteCode(), assignEdgeWise(), and unByteCodeAssign() 2015-04-28 warnes * [r1976] Changes to mixedsort(): - Hands off objects that are not character vectors to the default sort. - Add 'decreasing', 'na.last', and 'blank.last' arguments. * [r1975] Add private function 'checkReverseDependencies'. 2015-04-23 warnes * [r1950] Update NEWS and ChangeLog * [r1949] - The 'q' argument to quantcut()'s 'q' now accept an integer indicating the number of equally spaced quantile groups to create. (Suggestion and patch submitted by Ryan C. Thompson.) * [r1946] Revers accidental text deletion: * [r1945] Update for gtools 3.4.3 * [r1944] Remove debugging code and stray browser() call 2015-04-14 warnes * [r1923] Fix typo 2015-04-09 warnes * [r1921] Update gtools ChangeLog * [r1920] Move first()/last()/left()/right() to gdata. Add new functions na.replace() and loadedPackages(). Add more text to package description. 2015-04-08 warnes * [r1919] Move first/last/left/right to from gtools to gdata 2015-04-06 warnes * [r1918] Correct URL * [r1917] Update NEWS and ChangeLog for gtools 3.5.0 * [r1916] Add ChangeLog files to repository * [r1915] Implement fix to keywords() needed for R-3.4.1, as suggested by Kurt Hornik. * [r1914] - Export S3 methods for first(), last(), left() and right(). - Ensure code matches man page for first(), last(), left(), and right(). 2014-10-09 warnes * [r1897] Update for 3.5.0 release of gtools * [r1896] Make right() and left() S3 methods for classes data.frame and matrix 2014-08-27 warnes * [r1872] Fix man page * [r1871] Finish adding first(), last(), left(), and right(). * [r1870] Add functions first(), last(), left(), and right(). 2014-05-28 warnes * [r1816] Update for gtools 3.4.1 * [r1815] Add test to ensure smartbind() properly handles Date columns. * [r1814] smartbind: Convert non-native type columns (except factor) to character. 2014-04-18 arnima * [r1813] Main arg is 'x' like showNonASCII(x), preformatted notes instead of verb 2014-04-17 warnes * [r1810] Update ASCIIfy man page to match source code and add keywords * [r1809] Update NEWS for gtools 3.4.0 * [r1808] Add ASCIIfy function posted to RDevel by Arni Magnusson 2014-03-01 warnes * [r1776] Fix cut-and-paste error. * [r1775] Update files for gtools 3.3.1 release * [r1774] Fix bug in gtools::mixedorder regular expression for regognizing numbers. (Periods weren't escaped). 2014-02-11 warnes * [r1773] Create and use locate copy of tools:::.split_op_version. * [r1772] Update for gtools 3.3.0. * [r1771] Fix arguments * [r1770] Update arguments to match code. * [r1769] Add getDependencies() function to return a list of package dependencies. 2014-01-14 warnes * [r1768] Update for bug-fix release * [r1767] Add test file for binsearch() function. * [r1766] Fixed bug where binsearch() returned the wrong endpoint & value when the found value was at the upper endpoint. 2014-01-13 warnes * [r1765] Fix typo 2014-01-11 warnes * [r1764] Update for gtools release 3.2.0 * [r1763] fixes for R CMD check * [r1762] Fixes for gtools release 3.2.0 2013-12-23 warnes * [r1761] Extend the keywords() function to return keywords associated with a specified topic via 'keywords(topic)'. * [r1760] Add keyword. * [r1759] Add stars.pval() function to convert p-values into significance symbols. 2013-11-26 warnes * [r1748] 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] Use ".Deprecated" instead of warning. 2013-11-06 warnes * [r1746] Update files for gtools 3.1.1 * [r1745] Fix problem with mixedorder/mixedsort when there is only zero or one elements in the vector. 2013-09-23 warnes * [r1716] Comment out empty sections in gtools-deprecated.Rd * [r1715] Update files for gtools 3.1.0 release * [r1714] Make 'addLast()' defunct. * [r1713] Mark 'addLast()' as defunct and move 'lastAdd()' function to a separate file. * [r1712] Update for gtools 3.0.1 release * [r1711] Use 'suppressWarnings() instead of 'options(warn=-1)' in 'mixedorder()'. 2013-07-07 warnes * [r1705] Fix typo. 2013-07-06 warnes * [r1704] Fix Rd warning. * [r1703] Include lastAdd in NAMESPACE * [r1702] Change assert from deprecated to defunct. * [r1701] Improve deprecation message * [r1700] Update for gtools 3.0.0 * [r1699] Create new function lastAdd to replace addLast and mark addLast as deprecated. 2013-07-05 warnes * [r1698] Point out that addLast() modifies the value of .Last in the global environment. * [r1697] Point out that addLast() modifies the value of .Last in the global environment. * [r1696] Update for gtools 2.7.2 mark 2 * [r1695] Remove cross-reference to (obsolete?) moc package * [r1694] Update for gtools 2.7.2 * [r1693] Update for R version 3.0.0 and later 2013-03-17 warnes * [r1640] 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] Update for gtools 2.7.0. * [r1569] Document new 'verbose' argument to smartbind(). * [r1568] Clean up R CMD check warnings. 2012-05-04 warnes * [r1529] smartbind(): Improve handling of factors and ordered factors. 2011-10-05 warnes * [r1518] Update version number for release * [r1517] Add 'sep' argument to smartbind() to allow specification of character used to separate components of constructed names 2011-09-28 warnes * [r1513] smartbind(): Prevent coersion to data frame from mangling column names. * [r1512] Add 'fill' argument to smartbind() to specify a value to use for missing entries. * [r1511] Add 'fill' argument to smartbind() to specify a value to use for missing entries. 2010-08-14 warnes * [r1451] 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] Update version number for new release * [r1433] Change Greg's email address to greg@warnes.net * [r1432] Fix error in checkRVersion() 2010-04-28 ggrothendieck2 * [r1431] fixed problems with R CMD CHECK 2009-05-09 warnes * [r1328] Escape $ in .Rd file to avoid latex issues * [r1327] Update NEWS and create softlinks for NEWS and ChangeLog in top level directory * [r1326] Move actual NEWS file into inst. * [r1325] Update Greg's email address and fix Rd syntax errors 2009-02-16 warnes * [r1313] Correct windows make flags as suggested by Brian Ripley. 2008-08-15 warnes * [r1303] Add keywords() function to show /doc/KEYWORDS file 2008-05-29 warnes * [r1285] Add newVersionAvailable() function to compare running and latest available R versions 2008-05-26 warnes * [r1284] Update license specification * [r1283] Remove 'assert' man page 2008-05-22 warnes * [r1282] Finish rename of assert.R to assert-depricated.Rd * [r1281] Add checkRVersion.R file * [r1280] Rename again to get correct extension! * [r1279] Update NEWS for 2.5.0 * [r1278] Add man page for checkRVersion * [r1277] Rename assert-deprecated.R to assert.R to meet R file name requirements. * [r1276] Add checkRVersion to NAMESPACE, and increment version in DESCRIPTION. * [r1275] Remove broken SEE LSO reference 2008-04-12 warnes * [r1259] Improve text explanation of how defmacro() and strmacro() differ from function(). * [r1258] assert() is now deprecated in favor of base::stopifnot() * [r1257] Rename 'assert.R' to 'deprecated.R'. * [r1256] Assert is now deprecated in favor of base::stopifnot(), so add call to .Deprecated() to inform the user. 2007-11-30 warnes * [r1228] Update defnitions of odd() and even() to use modulus operator instead of division. Prettier, I think, :-D 2007-08-08 warnes * [r1121] Fix bug identified by R-2.6's check routings in binsearch() * [r1120] Add the binsearch(), previously in the genetics package. 2007-07-18 ggorjan * [r1100] typo fixed 2007-04-12 warnes * [r1088] Add ask() function to prompt the user and collect a single response. 2007-04-07 warnes * [r1087] Fix improper escapes in regexp detected by R 2.5.0 package check. 2007-03-23 warnes * [r1083] Allow permutations for r>n provided repeats.allowed=TRUE 2006-11-28 warnes * [r1023] Replace F with FALSE in smartbind example. 2006-11-27 warnes * [r1022] Replace T with TRUE in smartbind example * [r1021] Temprary remove to reset binary flag * [r1020] Temprary remove to reset binary flag * [r1019] Add smartbind() to list of exported functions, and add corresponding documentation file. * [r1018] Update my email address 2006-11-14 ggorjan * [r1012] Removed executable property 2006-08-02 warnes * [r977] Update my email address 2006-05-05 nj7w * [r958] Fixed minor typo - in {value} - n was replaced by r * [r957] Fixed minor typos 2006-03-01 warnes * [r903] Add smartbind function 2006-01-18 warnes * [r845] Add concept tags to make mixedsort easier to locate. 2005-12-21 warnes * [r837] Update version number and date * [r836] Note changes for 2.2.3 * [r835] Should now work on Windows 2005-12-20 warnes * [r834] 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] Change C++ comment to standard comment 2005-12-13 nj7w * [r810] *** empty log message *** * [r809] Updated NEWS and removed ChangeLog 2005-12-12 nj7w * [r800] Updated version for CRAN release 2005-12-08 warnes * [r790] Add C source code for setTCPNoDelay. 2005-12-01 nj7w * [r776] Updated Greg's email address 2005-11-29 warnes * [r769] Add UseDynLib to NAMESPACE so the shared library gets properly loaded. * [r768] - Remove debugging comments - Change return value on success to "Success". 2005-11-22 warnes * [r758] NAMESPACE * [r757] Update news for 2.2.1 release. * [r756] Fixes for R CMD check * [r755] Add setTCPNoDelay() function and documentation * [r745] 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] More changes for strmacro(), also changes for 2.1.1 release * [r677] Add strmaco() which defines functions that use strings for macro definition 2005-09-21 warnes * [r676] Add support for DOTS/... arguments to defmacro 2005-09-12 nj7w * [r671] Updated Greg's email 2005-09-02 nj7w * [r653] Exported assert * [r652] Updated the version number * [r651] Added NEWS * [r650] Added ChangeLog * [r649] Fixed syntax errors 2005-09-02 warnes * [r648] Add assert() and documentation * [r647] Fix problem in defmacro.Rd file: don't use \code{} in the example section. 2005-08-31 warnes * [r645] 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] Add stand-alone DESCRIPTION file and remove old DESCRIPTION.in file. 2005-06-13 nj7w * [r626] Fixed a bug in mixedsort - check if "which.na" and "which.blank" is numeric(0) before subsetting the datasets. 2005-06-09 nj7w * [r625] Updating the version number, and various help files to synchronize splitting of gregmisc bundle in 4 individual components. 2005-05-10 warnes * [r619] 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] - 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] Move drop.levels() from gtools to gdata. * [r599] Minor reordering of functions in file * [r598] Move frameApply() to gdata package. * [r597] Fix error if only one value passed to mixedorder. * [r596] Add proper handling where more than one quantile obtains the same value 2005-04-01 warnes * [r595] Add CVS ID tag to file headers. * [r594] Fixes from Jim Rogers for R CMD check problems in frameApply 2005-03-31 warnes * [r591] Updates to drop.levels() and frameApply() from Jim Rogers * [r590] Add ELISA data set used by frameApply and drop.levels examples 2005-02-25 warnes * [r562] Replace 'T' with TRUE. * [r561] Remove dependency on ELISA data set for the example. * [r558] Add drop.levels, frameApply to namespace export. 2005-02-15 warnes * [r542] Add frameApply and drop.levels contributed by Jim Rogers. 2005-01-12 warnes * [r515] 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] Updated to pass R CMD check. 2004-09-03 warneg * [r446] initial bundle checkin 2004-09-02 warneg * [r442] Initial revision 2004-08-27 warnes * [r441] Fixed bug in mixedsort, and modified reorder.factor to use mixedsort. 2004-08-26 warnes * [r440] - 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] Nitin Jain added by= parameter to allow specifying separation between groups. 2004-05-26 warnes * [r345] Escape underscores in email addresses so Latex is happy. * [r343] Replace 'T' with 'TRUE' to pass R CMD check. 2004-05-25 warnes * [r334] Remove extraneous comments. * [r333] 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] Check if argument is a vector before doing is.na to avoid generating a warning. * [r322] Add invalid() function for testing if a parameter value is non-missing, non-NA, non-NULL. 2004-04-27 warnes * [r321] Replaced argument `as.list' with `simplify'. Updated documentation, and updated examples appropriately. 2004-04-26 warnes * [r320] Added as.list argument to return one list element per evaluation. 2004-03-26 warnes * [r303] Uncomment and fix large 'n' example. * [r301] - Update to match changes in running() - Add examples to illustrate new arguments. - Modify running correlation plot example to be more clear. * [r299] More of the same. * [r297] 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] - 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] - match function argument defaults with 'usage' 2003-11-21 warnes * [r237] Removed 'deqn' call that was confusing things. * [r234] Add email address to author field * [r233] - new files * [r232] - Change 'T' to 'TRUE' in mixedsort.R - Add missing brace in mixedsort.Rd 2003-11-20 warnes * [r230] - Move 'odd' and 'even' functions to a separate file & provide documentation 2003-11-18 warnes * [r227] - Renamed smartsort to mixedsort and added documentation. 2003-11-10 warnes * [r220] - Add files contributed by Arni Magnusson . As well as some of my own. 2003-05-23 warnes * [r196] - 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] - Fixed tpyo in example that allowed combinations(500,2) to run when it should have been ignred for testing.. 2003-04-10 warnes * [r186] - 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] - 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] Checkin for version 0.5.3 2002-03-26 warneg * [r97] Initial Checkin * [r96] Initial checkin. 2002-03-20 warneg * [r91] - Added definition of is.R function. - Added boxplot.formula 2002-03-07 warneg * [r90] - Added documentation and example for running2 * [r89] - Added "running2", which handles both univariate and bivariate cases - Modified "running" to call "running2" 2002-02-05 warneg * [r75] - Fix typo that caused code meant to run only under S-Plus to run under R, causing problems. 2001-12-19 warneg * [r67] - Added code for %in%. 2001-09-18 warneg * [r18] Release 0.3.2 2001-09-01 warneg * [r17] Initial checkin. * [r16] Release 0.3.0 2001-08-25 warneg * [r13] Initial CVS checkin. * [r11] Fixed a typo and a syntax error. * [r7] Initial Checkin 2001-06-29 warneg * [r6] Initial revision. gtools/man/0000755000176000001440000000000012531372110012357 5ustar ripleyusersgtools/man/roman2int.Rd0000644000176000001440000000200112531230226014551 0ustar ripleyusers\name{roman2int} \alias{roman2int} \title{Convert Roman Numerals to Integers} \description{ Convert roman numerals to integers } \usage{ roman2int(roman) } \arguments{ \item{roman}{character vector containing roman numerals} } \details{ This functon will convert roman numerals to integers without the upper bound imposed by R (3899), ignoring case. } \value{ A integer vector with the same length as \code{roman}. Character strings which are not valid roman numerals will be converted to \code{NA}. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[utils]{as.roman}} } \examples{ roman2int( c('I', 'V', 'X', 'C', 'L', 'D', 'M' ) ) # works regardless of case roman2int( 'MMXVI' ) roman2int( 'mmxvi' ) # works beyond R's limit of 3899 val.3899 <- 'MMMDCCCXCIX' val.3900 <- 'MMMCM' val.4000 <- 'MMMM' as.numeric(as.roman( val.3899 )) as.numeric(as.roman( val.3900 )) as.numeric(as.roman( val.4000 )) roman2int(val.3899) roman2int(val.3900) roman2int(val.4000) } \keyword{arith} gtools/man/running.Rd0000644000176000001440000001071511367122427014344 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.Rd0000644000176000001440000000106212220061143016246 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/ASCIIfy.Rd0000644000176000001440000000262312521153025014041 0ustar ripleyusers\name{ASCIIfy} \alias{ASCIIfy} \title{Convert Characters to ASCII} \description{ Convert character vector to ASCII, replacing non-ASCII characters with single-byte (\samp{\x00}) or two-byte (\samp{\u0000}) codes. } \usage{ ASCIIfy(x, bytes = 2, fallback = "?") } \arguments{ \item{x}{a character vector, possibly containing non-ASCII characters.} \item{bytes}{either \code{1} or \code{2}, for single-byte (\samp{\x00}) or two-byte (\samp{\u0000}) codes.} \item{fallback}{an output character to use, when input characters cannot be converted.} } \value{ A character vector like \code{x}, except non-ASCII characters have been replaced with \samp{\x00} or \samp{\u0000} codes. } \author{Arni Magnusson \email{arnima@hafro.is}} \note{ To render single backslashes, use these or similar techniques:\preformatted{ write(ASCIIfy(x), "file.txt") cat(paste(ASCIIfy(x), collapse="\n"), "\n", sep="")} The resulting strings are plain ASCII and can be used in R functions and datasets to improve package portability. } \seealso{ \code{\link[tools]{showNonASCII}} identifies non-ASCII characters in a character vector. } \examples{ cities <- c("S\u00e3o Paulo", "Reykjav\u00edk") print(cities) ASCIIfy(cities, 1) ASCIIfy(cities, 2) athens <- "\u0391\u03b8\u03ae\u03bd\u03b1" print(athens) ASCIIfy(athens) } \keyword{utilites} \keyword{character} gtools/man/setTCPNoDelay.Rd0000644000176000001440000000336611367122427015306 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.Rd0000644000176000001440000000147611367122427013446 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.Rd0000644000176000001440000001044311367122427014442 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/getDependencies.Rd0000644000176000001440000000474712276455624015772 0ustar ripleyusers\name{getDependencies} \alias{getDependencies} \title{ Get package dependencies } \description{ Get package dependencies } \usage{ getDependencies(pkgs, dependencies = c("Depends", "Imports", "LinkingTo"), installed=TRUE, available=TRUE, base=FALSE, recommended=FALSE) } \arguments{ \item{pkgs}{character vector of package names} \item{dependencies}{character vector of dependency types to include. Choices are "Depends", "Imports", "LinkingTo", "Suggests", and "Enhances". Defaults to \code{c("Depends", "Imports", "LinkingTo")}. } \item{installed}{Logical indicating whether to pull dependency information from installed packages. Defaults to TRUE. } \item{available}{Logical indicating whether to pull dependency information from available packages. Defaults to TRUE. } \item{base}{Logical indicating whether to include dependencies on base packages that are included in the R installation. Defaults to FALSE. } \item{recommended}{Logical indicating whether to include dependencies on recommended packages that are included in the R installation. Defaults to FALSE. } } \details{ This function recursively constructs the list of dependencies for the packages given by \code{pkgs}. By default, the dependency information is extracted from both installed and available packages. As a consequence, it works both for local and CRAN packages. } \value{ A character vector of package names. } \note{ If \code{available=TRUE} R will attempt to access the currently selected CRAN repository, prompting for one if necessary. } \author{ Gregory R. Warnes email{greg@warnes.net} based on the non exported \code{utils:::getDependencies} and \code{utils:::.clean_up_dependencies2}. } \seealso{ \code{\link{installed.packages}}, \code{\link{available.packages}} } \examples{ ## A locally installed package getDependencies("MASS", installed=TRUE, available=FALSE) \dontrun{ ## A package on CRAN getDependencies("gregmisc", installed=FALSE, available=TRUE) } ## Show base and recommended dependencies getDependencies("MASS", available=FALSE, base=TRUE, recommended=TRUE) \dontrun{ ## Download the set of packages necessary to support a local package deps <- getDependencies("MyLocalPackage", available=FALSE) download.packages(deps, destdir="./R_Packages") } } \keyword{utilities} gtools/man/combinations.Rd0000644000176000001440000000406211367122427015347 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/unByteCode.Rd0000644000176000001440000000465312530630747014733 0ustar ripleyusers\name{unByteCode} \alias{unByteCode} \alias{unByteCodeAssign} \alias{assignEdgewise} \title{ Convert a Byte-Code Function to an Interpreted-Code Function } \description{ Convert a byte-code function to an interpreted-code function } \usage{ unByteCode(fun) assignEdgewise(name, env, value) unByteCodeAssign(fun) } \arguments{ \item{fun}{function to be modified} \item{name}{object name} \item{env}{namespace} \item{value}{new function body} } \details{ The purpose of these functions is to allow a byte coded function to be converted back into a fully interpreted function as a \emph{temporary} work around for issues in byte-code interpretation. \code{unByteCode} returns a copy of the function that is directly interpreted from text rather than from byte-code. \code{assignEdgewise} makes an assignment into a locked environemnt. \code{unByteCodeAssign} changes the specified function \emph{in its source environment} to be directly interpreted from text rather than from byte-code. } \value{ All three functions return a copy of the modified function or assigned value. } \references{ These functions were inspired as a work-around to R bug \url{https://bugs.r-project.org/bugzilla/show_bug.cgi?id=15215}. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \note{ These functions are not intended as a permanent solution to issues with byte-code compilation or interpretation. Any such issues should be promtply reported to the R maintainers via the R Bug Tracking System at \url{https://bugs.r-project.org} and via the R-devel mailing list \url{https://stat.ethz.ch/mailman/listinfo/r-devel}. } \seealso{ \code{\link[compiler]{disassemble}}, \code{\link{assign}} } \examples{ datURL <- "https://bugs.r-project.org/bugzilla/attachment.cgi?id=1659" dat <- as.matrix(read.csv(file=datURL, row.names=1)) dist2 <- function(x) as.dist(1-cor(t(x), method="pearson")) hclust1 <- function(x) hclust(x, method = "single") distance <- dist2(dat) cluster <- hclust1(distance) dend <- as.dendrogram(cluster) \dontrun{ ## In R 2.3.0 and earlier crashes R: with a node stack overflow error plot(dend) ## Error in xy.coords(x, y, recycle = TRUE) : node stack overflow } ## convert stats:::plotNode from byte-code to interpreted-code unByteCodeAssign(stats:::plotNode) # increase recursion limit options("expressions"=5e4) # now the function does not crash plot(dend) } \keyword{programming} \keyword{utilites} gtools/man/smartbind.Rd0000644000176000001440000000510312265026623014641 0ustar ripleyusers\name{smartbind} \alias{smartbind} \title{Efficient rbind of data frames, 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/asc.Rd0000644000176000001440000000372112531206760013426 0ustar ripleyusers\name{asc} \alias{asc} \alias{chr} \title{Convert between characters and ASCII codes} \description{ \code{asc} returns the ASCII codes for the specified characters. \code{chr} returns the characters corresponding to the specified ASCII codes. } \usage{ asc(char, simplify=TRUE) chr(ascii) } \arguments{ \item{char}{vector of character strings} \item{simplify}{logical indicating whether to attempt to convert the result into a vector or matrix object. See \code{\link[base]{sapply}} for details. } \item{ascii}{vector or list of vectors containing integer ASCII codes} } \value{ \code{asc} returns the integer ASCII values for each character in the elements of \code{char}. If \code{simplify=FALSE} the result will be a list contining one vector per element of \code{char}. If \code{simplify=TRUE}, the code will attempt to convert the result into a vector or matrix. \code{asc} returns the characters corresponding to the provided ASCII values. } \author{ Adapted by Gregory R. Warnes \email{greg@warnes.net} from code posted on the 'Data Debrief' blog on 2011-03-09 at \url{http://datadebrief.blogspot.com/2011/03/ascii-code-table-in-r.html}. } \seealso{ \code{\link[base]{strtoi}}, \code{\link[base]{charToRaw}}, \code{\link[base]{rawToChar}}, \code{\link[base]{as.raw}} } \examples{ ## ascii codes for lowercase letters asc(letters) ## uppercase letters from ascii codes chr(65:90) ## works on muti-character strings ( tmp <- asc('hello!') ) chr(tmp) ## Use 'simplify=FALSE' to return the result as a list ( tmp <- asc('hello!', simplify=FALSE) ) chr(tmp) ## When simplify=FALSE the results can be... asc( c('a', 'e', 'i', 'o', 'u', 'y' ) ) # a vector asc( c('ae', 'io', 'uy' ) ) # or a matrix ## When simplify=TRUE the results are always a list... asc( c('a', 'e', 'i', 'o', 'u', 'y' ), simplify=FALSE ) asc( c('ae', 'io', 'uy' ), simplify=FALSE) } \keyword{character} \keyword{programming} gtools/man/gtools-defunct.Rd0000644000176000001440000000150212264352765015622 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.Rd0000644000176000001440000000273112510602062014617 0ustar ripleyusers% $Id: dirichlet.Rd 1918 2015-04-06 22:09:54Z 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{https://stat.ethz.ch/pipermail/r-help/2000-December/009561.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.Rd0000644000176000001440000000162612264351244014760 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.Rd0000644000176000001440000000234612165653673014014 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.Rd0000644000176000001440000000105011367122427014335 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.Rd0000644000176000001440000000137011367122427013613 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.Rd0000644000176000001440000001104412531225763014677 0ustar ripleyusers\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 embedded 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, decreasing=FALSE, na.last=TRUE, blank.last=FALSE, numeric.type=c("decimal", "roman"), roman.case=c("upper","lower","both") ) mixedorder(x, decreasing=FALSE, na.last=TRUE, blank.last=FALSE, numeric.type=c("decimal", "roman"), roman.case=c("upper","lower","both") ) } \arguments{ \item{x}{Vector to be sorted.} \item{decreasing}{logical. Should the sort be increasing or decreasing? Note that \code{descending=TRUE} reverses the meanings of \code{na.last} and \code{blanks.last}.} \item{na.last}{for controlling the treatment of \code{NA} values. If \code{TRUE}, missing values in the data are put last; if \code{FALSE}, they are put first; if \code{NA}, they are removed.} \item{blank.last}{for controlling the treatment of blank values. If \code{TRUE}, blank values in the data are put last; if \code{FALSE}, they are put first; if \code{NA}, they are removed.} \item{numeric.type}{either "decimal" (default) or "roman". Are numeric values represented as decimal numbers (\code{numeric.type="decimal"}) or as Roman numerals (\code{numeric.type="roman"})? } \item{roman.case}{one of "upper", "lower", or "both". Are roman numerals represented using only capital letters ('IX') or lower-case letters ('ix') or both?} } \details{ I often have character vectors (e.g. factor labels), such as compound and dose, that contain both text and numeric data. 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") \emph{ignoring case} (e.g. 'A' has the same sort order as 'a'). By default, sort order is ascending, empty strings are sorted to the front, and \code{NA} values to the end. Setting \code{descending=TRUE} changes the sort order to descending and reverses the meanings of \code{na.last} and \code{blank.last}. Parsing looks for decimal numbers unless \code{numeric.type="roman"}, in which parsing looks for roman numerals, with character case specified by \code{roman.case}. } \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, NAs at the end, and blanks at the # beginning . mixedsort(x, na.last=TRUE) # default mixedsort(x, na.last=FALSE) # push NAs to the front mixedsort(x, blank.last=FALSE) # default mixedsort(x, blank.last=TRUE) # push blanks to the end mixedsort(x, decreasing=FALSE) # default mixedsort(x, decreasing=TRUE) # reverse sort order ## Roman numerals chapters <- c("V. Non Sequiturs", "II. More Nonsense", "I. Nonsense", "IV. Nonesensical Citations", "III. Utter Nonsense") mixedsort(chapters, numeric.type="roman" ) ## Lower-case Roman numerals vals <- c("xix", "xii", "mcv", "iii", "iv", "dcclxxii", "cdxcii", "dcxcviii", "dcvi", "cci") (ordered <- mixedsort(vals, numeric.type="roman", roman.case="lower")) roman2int(ordered) } \keyword{univar} \keyword{manip} \concept{natural sort} \concept{dictionary sort} gtools/man/loadedPackages.Rd0000644000176000001440000000200412511553321015534 0ustar ripleyusers\name{loadedPackages} \alias{loadedPackages} \title{ Provide Name, Version, and Path of Loaded Package Namespaces } \description{ Provide name, version, and path of loaded package namespaces } \usage{ loadedPackages(silent = FALSE) } \arguments{ \item{silent}{Logical indicating whether the results should be printed} } \value{ Data frame containing one row per loaded package namespace, with columns: \item{Package}{Package name} \item{Version}{Version string} \item{Path}{Path to package files} \item{SearchPath}{Either the index of the package namespace in the current search path, or '-' if the package namespace is not in the search path. '1' corresponds to the top of the search path (the first namespace searched for values). } } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[base]{loadedNamespaces}}, \code{\link[utils]{packageVersion}}, \code{\link[base]{search}}, \code{\link[base]{find.package}} } \examples{ loadedPackages() } \keyword{package} gtools/man/binsearch.Rd0000644000176000001440000001001711367122427014615 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.Rd0000644000176000001440000000066611367122427014314 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.Rd0000644000176000001440000000413112530626770014526 0ustar ripleyusers% $Id: quantcut.Rd 2025 2015-05-25 14:13:12Z 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=4, na.rm=TRUE, ...) } %- maybe also `usage' for other objects documented here. \arguments{ \item{x}{ Continous variable. } \item{q}{ Either a integer number of equally spaced quantile groups to create, or a vector of quantiles used for creating groups. Defaults to \code{q=4} which is equivalent to \code{q=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. } \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.1 <- quantcut( x, 10 ) table(deciles.1) # or equivalently deciles.2 <- quantcut( x, seq(0,1,by=0.1) ) \testonly{ stopifnot(identical(deciles.1, deciles.2)) } ## show handling of 'tied' quantiles. x <- round(x) # discretize to create ties stem(x) # display the ties deciles <- quantcut( x, 10 ) table(deciles) # note that there are only 5 groups (not 10) # due to duplicates } \keyword{ manip } gtools/man/lastAdd.Rd0000644000176000001440000000364212220060061014221 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.Rd0000644000176000001440000000305111367122427014751 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.Rd0000644000176000001440000000154111367122427014307 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/na.replace.Rd0000644000176000001440000000124412511553321014662 0ustar ripleyusers\name{na.replace} \alias{na.replace} \title{ Replace Missing Values } \description{ Replace missing values } \usage{ na.replace(x, replace) } \arguments{ \item{x}{vector possibly contining missing (\code{NA}) values.} \item{replace}{scalar replacement value} } \details{ This is a convenience function that is the same as x[is.na(x)] <- replace } \value{ Vector with missing values (\code{NA}) replaced by the value of \code{replace}. } \author{ Gregory R. Warnes \email{greg@warnes.net} } \seealso{ \code{\link[base]{is.na}}, \code{\link[stats]{na.omit}} } \examples{ x <- c(1,2,3,NA,6,7,8,NA,NA) na.replace(x, '999') } \keyword{ manip } gtools/man/checkRVersion.Rd0000644000176000001440000000251311015316222015412 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.Rd0000644000176000001440000000160010526441102013500 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.Rd0000644000176000001440000000121512256102557014526 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}