Skip to content

Commit d86ccc7

Browse files
Sync with 2.18.0.1 on CRAN
1 parent faee05c commit d86ccc7

File tree

144 files changed

+1020
-77007
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+1020
-77007
lines changed

DESCRIPTION

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Description: Various R programming tools for data manipulation, including:
55
- combining objects ('bindData', 'cbindX', 'combine', 'interleave'),
66
- character vector operations ('centerText', 'startsWith', 'trim'),
77
- factor manipulation ('levels', 'reorder.factor', 'mapLevels'),
8-
- obtaining information about R objects ('object.size', 'env',
8+
- obtaining information about R objects ('object.size', 'elem', 'env',
99
'humanReadable', 'is.what', 'll', 'keep', 'ls.funs',
1010
'Args','nPairs', 'nobs'),
1111
- manipulating MS-Excel formatted files ('read.xls',
@@ -23,31 +23,12 @@ Description: Various R programming tools for data manipulation, including:
2323
Depends: R (>= 2.3.0)
2424
SystemRequirements: perl (>= 5.10.0)
2525
Imports: gtools, stats, methods, utils
26-
Version: 2.19.0
27-
Date: 2020-10-09
28-
Authors@R: c(
29-
person(
30-
c("Gregory", "R."), "Warnes",
31-
email = c("greg@warnes.net"),
32-
role = c("aut", "cre")
33-
),
34-
person(
35-
"Arni", "Magnusson",
36-
email="Arni.magnusson@ices.dk",
37-
role="aut"
38-
),
39-
person("Ben", "Bolker", role="ctb"),
40-
person("Gregor", "Gorjanc", role="ctb"),
41-
person("Gabor", "Grothendieck", role="ctb"),
42-
person("Ales", "Korosec", role="ctb"),
43-
person("Thomas", "Lumley", rol="ctb"),
44-
person("Don", "MacQueen", role="ctb"),
45-
person("Jim", "Rogers", role="ctb"),
46-
person("inoui llc", role="fnd", )
47-
)
26+
Version: 2.18.0.1
27+
Date: 2017-06-05
28+
Author: Gregory R. Warnes, Ben Bolker, Gregor Gorjanc, Gabor
29+
Grothendieck, Ales Korosec, Thomas Lumley, Don MacQueen, Arni
30+
Magnusson, Jim Rogers, and others
4831
Maintainer: Gregory R. Warnes <greg@warnes.net>
4932
License: GPL-2
5033
NeedsCompilation: no
5134
Suggests: RUnit
52-
URL: https://github.com/r-gregmisc/gdata
53-
BugReports: https://github.com/r-gregmisc/gdata/issues

NAMESPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export(
1111
ConvertMedUnits,
1212
drop.levels,
1313
duplicated2,
14+
elem,
1415
env,
1516
first,
1617
'first<-',
@@ -36,15 +37,14 @@ export(
3637
reorder.factor,
3738
resample,
3839
right,
39-
# runPerlScript,
4040
sheetCount,
4141
sheetNames,
4242
startsWith,
4343
trim,
4444
trimSum,
4545
unmatrix,
4646
update.list,
47-
update.data.frame,
47+
#update.data.frame,
4848
upperTriangle,
4949
"upperTriangle<-",
5050
wideByFactor,
@@ -71,7 +71,7 @@ export(
7171
importFrom(stats, reorder)
7272
importFrom(stats, nobs)
7373
importFrom(gtools, mixedsort)
74-
importFrom(methods, is, slot, slotNames)
74+
importFrom(methods, is)
7575
importFrom(utils, data, download.file, head, read.csv, read.delim, read.table, tail, write.table)
7676

7777
S3method(reorder, factor)
@@ -171,4 +171,4 @@ S3method(right, matrix)
171171

172172
# update methods for list, data.frame
173173
S3method(update, list)
174-
S3method(update, data.frame)
174+
#S3method(update, data.frame)

R/elem.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# $Id: elem.R 625 2005-06-09 14:20:30Z nj7w $
2+
3+
elem <- function(object=1, unit=c("KB","MB","bytes"), digits=0,
4+
dimensions=FALSE)
5+
{
6+
.Deprecated("ll", package="gdata")
7+
ll(pos=object, unit=unit, digits=digits, dimensions=dimensions)
8+
}
9+

R/env.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ env <- function(unit="KB", digits=0)
44
{
55
object <- get(object.name, pos=pos)
66
size <- try(unclass(object.size(object)), silent=TRUE)
7-
if(class(size) == "try-error")
7+
if(inherits(size, "try-error"))
88
size <- 0
9-
size
9+
return(size)
1010
}
1111

1212
get.environment.size <- function(pos)
@@ -15,12 +15,13 @@ env <- function(unit="KB", digits=0)
1515
size <- 0
1616
else
1717
size <- sum(sapply(ls(pos,all.names=TRUE), get.object.size, pos=pos))
18-
size
18+
return(size)
1919
}
2020

2121
get.environment.nobjects <- function(pos)
2222
{
23-
length(ls(pos, all.names=TRUE))
23+
nobjects <- length(ls(pos,all.names=TRUE))
24+
return(nobjects)
2425
}
2526

2627
unit <- match.arg(unit, c("bytes","KB","MB"))

R/installXLSXsupport.R

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,58 @@
1+
## s$Id: read.xls.R 1423 2010-02-21 17:12:30Z ggrothendieck2 $
2+
13
installXLSXsupport <- function(perl="perl", verbose=FALSE)
24
{
5+
## determine proper path to perl executable
6+
perl <- if (missing(perl))
7+
findPerl(verbose = verbose)
8+
else
9+
findPerl(perl, verbose = verbose)
10+
11+
##
12+
## directories
13+
package.dir <- find.package('gdata')
14+
perl.dir <- file.path(package.dir,'perl')
15+
##
16+
##
17+
18+
cmd <- "install_modules.pl"
19+
sc <- file.path(perl.dir, cmd)
20+
21+
##
22+
##
23+
24+
##
25+
## execution command
26+
27+
cmd <- paste(shQuote(perl), shQuote(sc), sep=" ")
28+
29+
##
330

431
if(verbose)
5-
message("Attempting to install Perl libraries to support XLSX (Excel 2007+) file format..")
32+
{
33+
cat("\n")
34+
cat("Attempting to automaticall install Perl libraries to support XLSX (Excel 2007+) file format...\n")
35+
cat("\n")
36+
}
37+
38+
##
39+
40+
output <- system(cmd, intern=TRUE)
641

7-
output <- runPerlScript("install_modules.pl", perl=perl, verbose=verbose)
42+
##
43+
44+
if(verbose) cat("Results: ", output, "\n")
45+
46+
##
847

948
if( "XLSX" %in% xlsFormats(perl=perl, verbose=verbose) )
1049
{
11-
message("Perl XLSX support libraries successfully installed.")
50+
cat("\nPerl XLSX support libraries successfully installed.\n\n")
1251
invisible(TRUE)
1352
}
1453
else
1554
{
16-
stop("\nUnable to install Perl XLSX support libraries.\n\n")
55+
stop("\nUnable to install Perl XLSX support libraries.\n\n")
1756
invisible(FALSE)
1857
}
19-
2058
}

R/is.what.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ is.what <- function(object, verbose=FALSE)
33
do.test <- function(test, object)
44
{
55
result <- try(get(test)(object), silent=TRUE)
6-
if(length(result)!=1 || !is.logical(result) || is.na(result))
6+
if(!is.logical(result) || length(result)!=1 || is.na(result))
77
result <- NULL
8-
result
8+
return(result)
99
}
1010

1111
## Get all names starting with "is."
@@ -22,5 +22,5 @@ is.what <- function(object, verbose=FALSE)
2222
else
2323
output <- names(results)[results]
2424

25-
output
25+
return(output)
2626
}

R/keep.R

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
keep <- function(..., list=character(), all=FALSE, sure=FALSE)
1+
keep <- function(..., list=character(0), all=FALSE, sure=FALSE)
22
{
33
if(missing(...) && missing(list))
44
{
@@ -11,19 +11,13 @@ keep <- function(..., list=character(), all=FALSE, sure=FALSE)
1111
keep.elements <- match(list, ls(1,all.names=all))
1212
if(any(is.na(keep.elements)))
1313
{
14-
warning("you tried to keep '", list[which(is.na(keep.elements))[1]],
15-
"' which doesn't exist in workspace - nothing was removed")
14+
warning("you tried to keep \"", list[which(is.na(keep.elements))[1]],
15+
"\" which doesn't exist in workspace - nothing was removed", sep="")
1616
return(invisible(NULL))
1717
}
1818

19-
obj <- ls(1, all.names=all)[-keep.elements]
2019
if(sure)
21-
{
22-
rm(list=obj, pos=1)
23-
invisible(obj)
24-
}
20+
rm(list=ls(1,all.names=all)[-keep.elements], pos=1)
2521
else
26-
{
27-
obj
28-
}
22+
return(ls(1,all.names=all)[-keep.elements])
2923
}

R/left.R

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
left <- function(x, n=6L, ...) UseMethod("left")
2-
right <- function(x, n=6L, ...) UseMethod("right")
1+
left <- function(x, n=6L) UseMethod("left")
2+
right <- function(x, n=6L) UseMethod("left")
33

4-
.leftright <- function(
5-
x,
6-
n=6L,
7-
add.col.nums = TRUE,
8-
direction = c("left", "right"), # center?
9-
...
10-
)
4+
left.data.frame <- function(x, n=6)
5+
{
6+
stopifnot(length(n) == 1L)
7+
n <- if (n < 0L)
8+
max(ncol(x) + n, 0L)
9+
else min(n, ncol(x))
10+
x[, seq_len(n), drop = FALSE]
11+
}
12+
left.matrix <- left.data.frame
13+
14+
15+
right.data.frame <- function (x, n = 6L, ...)
1116
{
1217
stopifnot(length(n) == 1L)
13-
1418
ncx <- ncol(x)
15-
16-
if (add.col.nums && is.null(colnames(x)))
17-
colnames(x) <- paste0("[", 1:ncx, ",]")
18-
19-
if (n < 0L)
20-
n <- max(ncx + n, 0L)
21-
else
22-
n <- min(n, ncx)
23-
24-
if(direction=="left")
25-
sel <- seq.int(from=1, length.out = n)
26-
else # direction="right"
27-
sel <- seq.int(to = ncx, length.out = n)
28-
29-
x[, sel, drop = FALSE]
19+
n <- if (n < 0L)
20+
max(ncx + n, 0L)
21+
else min(n, ncx)
22+
x[, seq.int(to = ncx, length.out = n), drop = FALSE]
3023
}
3124

32-
left.data.frame <- function(x, n=6L, add.col.nums=TRUE, ...)
33-
.leftright(x, n=n, add.col.nums=add.col.nums, direction="left")
25+
right.matrix <- function (x, n = 6L, addcolnums = TRUE, ...)
26+
{
27+
stopifnot(length(n) == 1L)
28+
ncx <- ncol(x)
29+
n <- if (n < 0L)
30+
max(ncx + n, 0L)
31+
else min(n, ncx)
32+
sel <- seq.int(to = ncx, length.out = n)
33+
ans <- x[, sel, drop = FALSE]
34+
if (addcolnums && is.null(colnames(x)))
35+
colnames(ans) <- paste0("[", sel, ",]")
36+
ans
37+
}
3438

35-
right.data.frame <- function(x, n=6L, add.col.nums=TRUE, ...)
36-
.leftright(x, n=n, add.col.nums=add.col.nums, direction="right")
37-
38-
left.matrix <- left.data.frame
39-
right.matrix <- right.data.frame

R/ll.R

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
ll <- function(pos=1, unit="KB", digits=0, dim=FALSE, sort=FALSE, class=NULL,
2-
invert=FALSE, standard="SI", ...)
2+
invert=FALSE, ...)
33
{
44
get.object.class <- function(object.name, pos)
55
{
66
object <- get(object.name, pos=pos)
7-
class(object)[1]
7+
class <- class(object)[1]
8+
return(class)
89
}
910

1011
get.object.dim <- function(object.name, pos)
@@ -16,26 +17,26 @@ ll <- function(pos=1, unit="KB", digits=0, dim=FALSE, sort=FALSE, class=NULL,
1617
dim <- paste(dim(object), collapse=" x ")
1718
else
1819
dim <- length(object)
19-
dim
20+
return(dim)
2021
}
2122

2223
get.object.size <- function(object.name, pos)
2324
{
2425
object <- get(object.name, pos=pos)
2526
size <- try(unclass(object.size(object)), silent=TRUE)
26-
if(class(size) == "try-error")
27+
if(inherits(size,"try-error"))
2728
size <- 0
28-
size
29+
return(size)
2930
}
3031

31-
## 1 Set original.rank
32+
## 1 Set unit, denominator, original.rank
33+
unit <- match.arg(unit, c("bytes","KB","MB"))
34+
denominator <- switch(unit, "KB"=1024, "MB"=1024^2, 1)
3235
original.rank <- NULL
3336

3437
## 2 Detect what 'pos' is like, then get class, size, dim
3538
if(is.character(pos)) # pos is an environment name
3639
pos <- match(pos, search())
37-
if(isS4(pos)) # pos is an S4 object
38-
pos <- sapply(slotNames(pos), slot, object=pos, simplify=FALSE)
3940
if(is.list(pos)) # pos is a list-like object
4041
{
4142
if(is.null(names(pos)))
@@ -62,27 +63,13 @@ ll <- function(pos=1, unit="KB", digits=0, dim=FALSE, sort=FALSE, class=NULL,
6263
}
6364
else
6465
{
65-
class.vector <- sapply(ls(pos,...),
66-
get.object.class,
67-
pos=pos)
68-
69-
size.vector <- sapply(ls(pos,...),
70-
get.object.size,
71-
pos=pos)
72-
73-
row.names <- names(size.vector)
74-
75-
size.vector <- humanReadable(size.vector,
76-
units=unit,
77-
standard=standard,
78-
digits=digits)
79-
66+
class.vector <- sapply(ls(pos,...), get.object.class, pos=pos)
67+
size.vector <- sapply(ls(pos,...), get.object.size, pos=pos)
68+
size.vector <- round(size.vector/denominator, digits)
8069
object.frame <- data.frame(class.vector=class.vector,
8170
size.vector=size.vector,
82-
row.names=row.names)
83-
71+
row.names=names(size.vector))
8472
names(object.frame) <- c("Class", unit)
85-
8673
if(dim)
8774
object.frame <- cbind(object.frame,
8875
Dim=sapply(ls(pos,...),get.object.dim,pos=pos))
@@ -101,5 +88,5 @@ ll <- function(pos=1, unit="KB", digits=0, dim=FALSE, sort=FALSE, class=NULL,
10188
object.frame <- object.frame[include,]
10289
}
10390

104-
object.frame
91+
return(object.frame)
10592
}

0 commit comments

Comments
 (0)