Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged from main

git-svn-id: https://svn.r-project.org/R/branches/WinMake@30094 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information...
commit 3b28265bc47e90ead7bae3d60a433a671c7c4070 1 parent 0120d00
ripley authored
View
36 BUGS
@@ -642,10 +642,6 @@ Date: Fri, 21 May 2004 15:24:05 +0200 (CEST)
Subject: Crash in OSX
From: murray.pung@studentmail.newcastle.edu.au
Date: Sat, 5 Jun 2004 04:36:52 +0200 (CEST)
-* PR# 6982 *
-Subject: out-of-date information in R for Mac OS X FAQ
-From: d.firth@warwick.ac.uk
-Date: Tue, 15 Jun 2004 12:50:38 +0200 (CEST)
Directory: Misc
@@ -907,3 +903,35 @@ Date: Fri, 25 Jun 2004 11:03:31 +0200
Subject: RE:znvvbi,UPTD - NEW stock pick - last pick up 200% - Set to explode on Monday
From: "Kelvin " <sbekoau@tiscali.fr>
Date: Sat, 26 Jun 2004 22:23:11 -0300
+* PR# 7027 *
+Subject: Problem with hasArg and the ... argument
+From: j.j.goeman@lumc.nl
+Date: Mon, 28 Jun 2004 11:12:27 +0200 (CEST)
+* PR# 7028 *
+Subject: how are you?
+From: "Katelyn Nova" <cfhqw8mctd@nni.com>
+Date: Tue, 29 Jun 2004 04:30:58 +0100
+* PR# 7029 *
+Subject: lowCost meds
+From: "Helen " <FGSBNMEWALIVBP@dallas.net>
+Date: Tue, 29 Jun 2004 11:03:17 +0600
+* PR# 7030 *
+Subject: input file and console command size limit
+From: jerome.mutterer@ibmp-ulp.u-strasbg.fr
+Date: Tue, 29 Jun 2004 09:00:36 +0200 (CEST)
+* PR# 7031 *
+Subject: vfont and title()
+From: "Warnes, Gregory R" <gregory_r_warnes@groton.pfizer.com>
+Date: Tue, 29 Jun 2004 10:23:47 -0400
+* PR# 7032 *
+Subject: Best and very cheeap-warez 0ffers! Let's se our prices.. here. irreconcilable
+From: <Clara@cocolee.net>
+Date: Tue, 29 Jun 2004 22:10:48 +0400
+* PR# 7033 *
+Subject: WE SEND OUT ORIGINAL SOFTWARES AT CHEAP (FROM $20) TO WORLDWIDE let
+From: "Valene Tanna" <zis4ps@ultimanet.com>
+Date: Tue, 29 Jun 2004 11:38:44 -0700
+* PR# 7034 *
+Subject: ky Windows 2003 Server Datacenter
+From: "Lacy Aragon" <Roafvss@ixpres.com>
+Date: Tue, 29 Jun 2004 14:44:02 -0600
View
9 NEWS
@@ -121,9 +121,9 @@ NEW FEATURES
o There is a new atomic vector type, class "raw". See ?raw for
full details including the operators and utility functions provided.
- o The png() and jpeg() devices (and the bmp() device under Windows)
+ o The png() and jpeg() devices (and the bmp() device under Windows)
now allow a nominal resolution to be recorded in the file.
-
+
o ls.str() and lsf.str() now return an object of class "ls_str" which
has a print method.
@@ -141,6 +141,8 @@ NEW FEATURES
o make.names() has a new argument allow_, which if false allows
its behaviour in R 1.8.1 to be reproduced.
+ o rank() has two new 'ties.method's, "min" and "max".
+
UTILITIES
@@ -271,6 +273,9 @@ BUG FIXES
o window() failed if both start and end were outside the time
range of the original series (possible if extend = TRUE).
+ o coplot(..) doesn't give an extraneous warning anymore when called
+ on a fresh device.
+
CHANGES IN R VERSION 1.9.1
View
2  date-stamp
@@ -1 +1 @@
-2004/06/28
+2004/06/30
View
6 src/extra/pcre/Makefile.win
@@ -3,10 +3,10 @@ include ../../gnuwin32/MkRules
CFLAGS = -I../../include -I. -O2 -DWIN32
-all: libRpcre.a
+all: libpcre.a
pcre.o: pcre.c chartables.h
-libRpcre.a: get.o maketables.o pcre.o study.o
+libpcre.a: get.o maketables.o pcre.o study.o
## this can't be used if cross-building, so ship the file
ifneq ($(strip $(BUILD)),CROSS)
@@ -19,7 +19,7 @@ chartables.h: chartables.h.win
endif
clean:
- $(RM) *.o *~ libRpcre.a
+ $(RM) *.o *~ libpcre.a
distclean: clean
$(RM) chartables.h dftables.exe
View
4 src/extra/xdr/Makefile.win
@@ -3,9 +3,9 @@ include ../../gnuwin32/MkRules
CFLAGS=-O2 -I. -DWIN32 -D_X86_
-xdr.a: xdr.o xdr_float.o xdr_stdio.o xdr_mem.o
+libxdr.a: xdr.o xdr_float.o xdr_stdio.o xdr_mem.o
clean:
$(RM) *.o *~
distclean: clean
- $(RM) xdr.a
+ $(RM) libxdr.a
View
64 src/gnuwin32/fixed/Makefile
@@ -1,77 +1,51 @@
include ../MkRules
-all: profiles fixh fixhtml fixbin fixetc fixshare
+R_HOME = ../../..
-profiles: ../../../library/base/R/Rprofile
+all: profiles fixhtml fixbin fixetc fixshare
-../../../library/base/R/Rprofile: ../../library/profile/Common.R \
+profiles: $(R_HOME)/library/base/R/Rprofile
+
+$(R_HOME)/library/base/R/Rprofile: ../../library/profile/Common.R \
../../library/profile/Rprofile.windows
@$(ECHO) -------- Building $@ from $^--------
- mkdir -p ../../../library/base/R
+ mkdir -p $(R_HOME)/library/base/R
@$(CAT) $^ > $@
-
-fixh: h/config.h h/psignal.h
- @$(CP) -p ./h/config.h ./h/psignal.h ../../include
- @$(ECHO) done > fixh
-
-../../../bin/massage-Examples: ../../../share/perl/massage-Examples.pl
- $(SED) -e 's/"contr.poly")/"contr.poly"), pager="console"/' $< > $@
-
-../../../bin/check: ../../scripts/check.in
- $(SED) -e 1d $< > $@
-
-../../../bin/build: ../../scripts/build.in
- $(SED) -e 1d $< > $@
-
-../../../bin/Sd2Rd: ../../scripts/Sd2Rd.in
- $(SED) -e 1d $< > $@
-
-../../../bin/Rdconv: ../../scripts/Rdconv.in
- $(SED) -e 1d -e s/\"unix\"/\"windows\"/ $< > $@
-
-../../../bin/Rdiff.sh: ../../scripts/Rdiff
- $(SED) -e 1d -e 's/\$${EGREP}/grep -E/' $< > $@
-
-../../../bin/Rprof: ../../scripts/Rprof.in
- $(SED) -e 1d $< > $@
-
-fixbin: ../../../bin/massage-Examples ../../../bin/build \
- ../../../bin/check ../../../bin/Rdconv \
- ../../../bin/Sd2Rd ../../../bin/Rdiff.sh ../../../bin/Rprof cp2bin
+fixbin: cp2bin
@$(ECHO) done > fixbin
cp2bin: $(filter-out ./bin/CVS, $(wildcard ./bin/*))
ifeq ($(strip $(BUILD)),CROSS)
@zip -ql bins $^
- @unzip -oq bins -d ../../..
+ @unzip -oq bins -d $(R_HOME)
else
@zip -q bins $^
- @unzip -oaq bins -d ../../..
+ @unzip -oaq bins -d $(R_HOME)
endif
@$(RM) bins.zip
-fixhtml: $(wildcard ./html/*.html) ../../../doc/html/search/SearchEngine.html
- $(CP) -p ./html/*.html ../../../doc/html
- $(CP) -p ./html/rwin.html ../../../doc/html/index.html
+fixhtml: html/rwin.html $(R_HOME)/doc/html/search/SearchEngine.html
+ $(CP) -p html/rwin.html $(R_HOME)/doc/html
+ $(CP) -p html/rwin.html $(R_HOME)/doc/html/index.html
@$(ECHO) done > fixhtml
fixetc: $(filter-out ./etc/CVS, $(wildcard ./etc/*))
- $(CP) -p $^ ../../../etc
+ $(CP) -p $^ $(R_HOME)/etc
@$(ECHO) done > fixetc
-fixshare: ./share/tests.mk
- $(MKDIR) -p ../../../share/make
- $(CP) -p $^ ../../../share/make/wintests.mk
+fixshare: share/tests.mk
+ $(MKDIR) -p $(R_HOME)/share/make
+ $(CP) -p $^ $(R_HOME)/share/make/wintests.mk
@$(ECHO) done > fixshare
clean:
- $(RM) *~ */*~ fixhtml fixh fixbin fixetc fixshare
+ $(RM) *~ */*~ fixhtml fixbin fixetc fixshare
distclean:
-../../../doc/html/search/SearchEngine.html: ../../../doc/html/search/SearchEngine-head.html ../../../doc/html/search/SearchEngine-foot.html ../../../doc/KEYWORDS.db
- (cd ../../../doc; \
+$(R_HOME)/doc/html/search/SearchEngine.html: $(R_HOME)/doc/html/search/SearchEngine-head.html $(R_HOME)/doc/html/search/SearchEngine-foot.html $(R_HOME)/doc/KEYWORDS.db
+ (cd $(R_HOME)/doc; \
cat html/search/SearchEngine-head.html > html/search/SearchEngine.html; \
perl ../tools/keywords2html.pl KEYWORDS.db >> html/search/SearchEngine.html; \
cat html/search/SearchEngine-foot.html >> html/search/SearchEngine.html)
View
11 src/gnuwin32/help/Makefile
@@ -6,32 +6,33 @@ CP=cp
RM=rm
MKDIR=mkdir
+R_HOME = ../../..
RHOME=$(shell perl ../pwd.pl ../../..)
PKGDIR=../../library
RLIB=$(RHOME)/library
indices:
@PERL5LIB=$(RHOME)/share/perl $(PERL) \
- ../../../share/perl/build-help-windows.pl ${DOS} -htmllists
+ $(R_HOME)/share/perl/build-help-windows.pl ${DOS} -htmllists
pkg-% help-%:
@if test -d $(PKGDIR)/$*/man ; then \
PERL5LIB=$(RHOME)/share/perl $(PERL) \
- ../../../share/perl/build-help-windows.pl ${DOS} \
+ $(R_HOME)/share/perl/build-help-windows.pl ${DOS} \
-txt -html -example -latex $(PKGDIR)/$* $(RLIB) '$(DPKG)' $* ; \
fi
pkgfake-%:
@if test -d $(PKGDIR)/$*/man ; then \
PERL5LIB=$(RHOME)/share/perl $(PERL) \
- ../../../share/perl/build-help-windows.pl ${DOS} \
+ $(R_HOME)/share/perl/build-help-windows.pl ${DOS} \
-latex $(PKGDIR)/$* $(RLIB) '$(DPKG)' $* ; \
fi
chm-%:
@if test -d $(PKGDIR)/$*/man ; then \
PERL5LIB=$(RHOME)/share/perl $(PERL) \
- ../../../share/perl/build-help-windows.pl ${DOS} \
+ $(R_HOME)/share/perl/build-help-windows.pl ${DOS} \
-chm $(PKGDIR)/$* $(RLIB) '$(DPKG)' $* ; \
$(MAKE) --no-print-directory -C $(PKGDIR)/$*/chm \
-f $(RHOME)/src/gnuwin32/help/Makefile $*.chm ; \
@@ -52,7 +53,7 @@ latex-%:
@$(MAKE) --no-print-directory -C $(RLIB)/$* \
-f $(RHOME)/src/gnuwin32/help/Makefile PKG=$* unzipit
PERL5LIB=$(RHOME)/share/perl $(PERL) \
- ../../../share/perl/build-help-windows.pl ${DOS} \
+ $(R_HOME)/share/perl/build-help-windows.pl ${DOS} \
-latex $(PKGDIR)/$* $(RLIB)
clean:
View
9 src/gnuwin32/installer/Makefile
@@ -1,9 +1,9 @@
# Makefile for R for Windows Installers
include ../MkRules
-include ../../../share/make/vars.mk
-
R_HOME = ../../..
+include $(R_HOME)/share/make/vars.mk
+
RPREFIX = $(shell perl ../fixed/rwver.pl $(R_HOME)/VERSION)
LIBFILES = $(foreach i, $(R_PKGS_BASE) $(R_PKGS_RECOMMENDED), $(R_HOME)/library/$i) $(R_HOME)/library/R.css
@@ -28,7 +28,7 @@ imagedir:
$(MKDIR) -p $(RPREFIX)/library
$(CP) -pr $(LIBFILES) $(RPREFIX)/library
# morley.tab is needed for R-intro Appendix A
- $(CP) -p ../../library/base/data/morley.tab $(RPREFIX)/library/base/data
+ $(CP) -p $(R_HOME)/src/library/base/data/morley.tab $(RPREFIX)/library/base/data
$(RM) $(RPREFIX)/*/Makefile.in
$(MKDIR) -p $(RPREFIX)/etc
$(CP) -p $(foreach i,$(ETC_FILES),$(R_HOME)/etc/$i) $(RPREFIX)/etc
@@ -37,7 +37,9 @@ imagedir:
$(CP) -pr $(R_HOME)/doc/html $(RPREFIX)/doc
$(CP) -p $(R_HOME)/doc/manual/*.html $(R_HOME)/doc/manual/*.pdf \
$(RPREFIX)/doc/manual
+# html copies of these are in doc/html, and we don't have PDFs on menus
$(RM) $(RPREFIX)/doc/manual/R-FAQ.html $(RPREFIX)/doc/manual/R-FAQ.pdf
+ $(RM) $(RPREFIX)/doc/manual/R-admin.html $(RPREFIX)/doc/manual/R-admin.pdf
#
$(CP) -p $(foreach i,$(INFO_FILES),$(R_HOME)/$i) $(RPREFIX)
$(CP) -p $(foreach i,$(GW_INFO_FILES),../$i) $(RPREFIX)
@@ -68,7 +70,6 @@ endif
(cd ..; $(MAKE) --no-print-directory -C installer/$(RPREFIX)/src/gnuwin32/help clean)
$(CP) -pr $(R_HOME)/include $(R_HOME)/lib $(RPREFIX)
$(CP) -pr $(foreach i,$(SHARE_DIRS),$(R_HOME)/share/$i) $(RPREFIX)/share
- $(CP) -p ../graphapp/graphapp.h ../graphapp/ga.h $(RPREFIX)/include
(cd ..; $(MAKE) --no-print-directory PKGDIR=. pkgclean-windlgs)
$(CP) -pr ../windlgs $(RPREFIX)/src/library
#
View
1  src/gnuwin32/windlgs/src/Makevars
@@ -1 +0,0 @@
-CFLAGS+= -I$(RHOME)/src/gnuwin32/graphapp
View
25 src/include/Makefile.win
@@ -5,30 +5,39 @@ R_HOME=../..
## keep these in step with ./Makefile.in
SRC_HEADERS = R.h S.h Rdefines.h Rdevices.h Rgraphics.h Rinternals.h
OBJ_HEADERS = Rconfig.h Rmath.h Rversion.h
+GW32_HEADERS = config.h psignal.h
all: fixh
@echo 'installing C headers'
@mkdir -p $(R_HOME)/include/R_ext
@cp -p $(SRC_HEADERS) $(OBJ_HEADERS) $(R_HOME)/include
@cp -p R_ext/*.h $(R_HOME)/include/R_ext
+ @cp -p ../gnuwin32/graphapp/graphapp.h ../gnuwin32/graphapp/ga.h \
+ $(R_HOME)/include
version: Rversion.h
-fixh: $(OBJ_HEADERS)
+fixh: $(GW32_HEADERS) $(OBJ_HEADERS)
@$(ECHO) done > fixh
+config.h: ../gnuwin32/fixed/h/config.h
+ @cp $< $@
+
+psignal.h: ../gnuwin32/fixed/h/psignal.h
+ @cp $< $@
+
Rconfig.h: config.h $(R_HOME)/tools/GETCONFIG
- $(SED) -e 1d $(R_HOME)/tools/GETCONFIG > GC
- sh GC > Rconfig.h
- $(RM) GC
+ @$(SED) -e 1d $(R_HOME)/tools/GETCONFIG > GC
+ @sh GC > Rconfig.h
+ @$(RM) GC
Rversion.h: $(R_HOME)/date-stamp $(R_HOME)/VERSION
- $(SED) -e 1d $(R_HOME)/tools/GETVERSION > $(R_HOME)/tools/GV
- sh $(R_HOME)/tools/GV > $@
- $(RM) $(R_HOME)/tools/GV
+ @$(SED) -e 1d $(R_HOME)/tools/GETVERSION > $(R_HOME)/tools/GV
+ @sh $(R_HOME)/tools/GV > $@
+ @$(RM) $(R_HOME)/tools/GV
Rmath.h0: Rmath.h0.in $(R_HOME)/VERSION
- $(SED) -e 's/@RMATH_HAVE_LOG1P@/# define HAVE_LOG1P 1/' \
+ @$(SED) -e 's/@RMATH_HAVE_LOG1P@/# define HAVE_LOG1P 1/' \
-e /@RMATH_HAVE_EXPM1@/d \
-e 's/@RMATH_HAVE_WORKING_LOG1P@/# define HAVE_WORKING_LOG1P 1/' \
-e "s/@PACKAGE_VERSION@/`sed 's/\([^ ]*\).*/\1/' < $(R_HOME)/VERSION`/" $< > Rmath.h0
View
6 src/library/base/R/rank.R
@@ -1,9 +1,11 @@
-rank <- function(x, na.last = TRUE, ties.method=c("average", "first", "random"))
+rank <- function(x, na.last = TRUE,
+ ties.method=c("average", "first", "random", "max", "min"))
{
nas <- is.na(x)
ties.method <- match.arg(ties.method)
y <- switch(ties.method,
- "average" = .Internal(rank( x[!nas])),
+ "average"= , "min"= , "max" =
+ .Internal(rank( x[!nas], ties.method)),
"first" = sort.list(sort.list(x[!nas])),
"random" = sort.list(order( x[!nas], runif(sum(!nas)))))
if(!is.na(na.last) && any(nas)) {
View
13 src/library/base/man/rank.Rd
@@ -6,7 +6,8 @@
Ties, i.e., equal values, result in ranks being averaged, by default.
}
\usage{
-rank(x, na.last = TRUE, ties.method = c("average", "first", "random"))
+rank(x, na.last = TRUE,
+ ties.method = c("average", "first", "random", "max", "min"))
}
\arguments{
\item{x}{a numeric vector.}
@@ -30,7 +31,10 @@ rank(x, na.last = TRUE, ties.method = c("average", "first", "random"))
the result at the corresponding indices. The \code{"first"} method
results in a permutation with increasing values at each index set of
ties. The \code{"random"} method puts these in random order whereas the
- default, \code{"average"}, replaces them by their mean.
+ default, \code{"average"}, replaces them by their mean, and
+ \code{"max"} and \code{"min"} replaces them by their maximum and
+ minimum respectively, the latter being the typical \dQuote{sports}
+ ranking.
}
\seealso{\code{\link{order}} and \code{\link{sort}}.}
\examples{
@@ -46,5 +50,10 @@ stopifnot(rank(r1) == r1, rank(r2) == r2)
rank(x2, ties.method= "first") # first occurrence wins
rank(x2, ties.method= "random") # ties broken at random
rank(x2, ties.method= "random") # and again
+
+## keep ties ties, no average
+(rma <- rank(x2, ties.method= "max")) # as used classically
+(rmi <- rank(x2, ties.method= "min")) # as in Sports
+stopifnot(rma + rmi == round(r2 + r2))
}
\keyword{univar}
View
11 src/library/base/man/read.table.Rd
@@ -88,6 +88,9 @@ read.delim2(file, header = TRUE, sep = "\t", quote="\"", dec=",",
Note: to suppress all conversions including those of numeric
columns, set \code{colClasses = "character"}.
+
+ Note that \code{as.is} is specified per column (not per
+ variable) and so includes the column of row names (if any).
}
\item{na.strings}{a vector of strings which are to be interpreted as
@@ -100,7 +103,13 @@ read.delim2(file, header = TRUE, sep = "\t", quote="\"", dec=",",
character, raw), there needs to be an \code{as} method for
conversion from \code{"character"} to the specified class, or
\code{NA} when \code{\link{type.convert}} is used. NB: \code{as} is
- in package \pkg{methods}.}
+ in package \pkg{methods}. Note that \code{colClasses} and
+ \code{as.is} are specified per column, not per variable, and so
+ include the column of row names (if any).
+
+ Note that \code{colClasses} is specified per column (not per
+ variable) and so includes the column of row names (if any).
+ }
\item{nrows}{the maximum number of rows to read in. Negative values
are ignored.}
View
3  src/library/graphics/R/coplot.R
@@ -198,9 +198,8 @@ coplot <-
if(a.is.fac && show.given[1]) oma[3] <- oma[3] - 1
## Start Plotting only now
-
opar <- par(mfrow = c(total.rows, total.columns),
- oma = oma, mar = mar, xaxs = "r", yaxs = "r", new = FALSE)
+ oma = oma, mar = mar, xaxs = "r", yaxs = "r")
on.exit(par(opar))
plot.new()
## as.numeric() allowing factors for x & y:
View
6 src/library/utils/man/citation.Rd
@@ -49,9 +49,9 @@ bibtex(object, ...)
## the basic R reference
citation()
-## references for a packages
-citation("lattice")
-citation("foreign")
+## references for a package -- might not have these installed
+if(nchar(system.file(package="lattice"))) citation("lattice")
+if(nchar(system.file(package="foreign"))) citation("foreign")
## extract the bibtex entry from the return value
x <- citation()
View
2  src/main/names.c
@@ -628,7 +628,7 @@ FUNTAB R_FunTab[] =
{"qsort", do_qsort, 0, 11, 2, {PP_FUNCALL, PREC_FN, 0}},
{"radixsort", do_radixsort, 0, 11, 3, {PP_FUNCALL, PREC_FN, 0}},
{"order", do_order, 0, 11, -1, {PP_FUNCALL, PREC_FN, 0}},
-{"rank", do_rank, 0, 11, 1, {PP_FUNCALL, PREC_FN, 0}},
+{"rank", do_rank, 0, 11, 2, {PP_FUNCALL, PREC_FN, 0}},
{"missing", do_missing, 1, 0, 1, {PP_FUNCALL, PREC_FN, 0}},
{"nargs", do_nargs, 1, 0, 0, {PP_FUNCALL, PREC_FN, 0}},
{"scan", do_scan, 0, 11, 16, {PP_FUNCALL, PREC_FN, 0}},
View
8 src/main/serialize.c
@@ -2026,7 +2026,7 @@ static SEXP readStringFromFile(SEXP file, SEXP key)
return val;
}
-/* Gets the vinding values of variables from a frame and returns them
+/* Gets the binding values of variables from a frame and returns them
as a list. If the force argument is true, promises are forced;
otherwise they are not. */
@@ -2039,7 +2039,7 @@ SEXP R_getVarsFromFrame(SEXP vars, SEXP env, SEXP forcesxp)
if (TYPEOF(env) != NILSXP && TYPEOF(env) != ENVSXP)
error("bad environment");
if (TYPEOF(vars) != STRSXP)
- error("bad varaible names");
+ error("bad variable names");
force = asLogical(forcesxp);
len = LENGTH(vars);
@@ -2087,9 +2087,9 @@ SEXP R_lazyLoadDBinsertValue(SEXP value, SEXP file, SEXP ascii,
return key;
}
-/* Retireves a sequence of bytes as specified by a position/length key
+/* Retrieves a sequence of bytes as specified by a position/length key
from a file, optionally decompresses, and unserializes the bytes.
- If the result is a promise, then the promise ir forced. */
+ If the result is a promise, then the promise is forced. */
SEXP R_lazyLoadDBfetch(SEXP key, SEXP file, SEXP compsxp, SEXP hook)
{
View
25 src/main/sort.c
@@ -2,6 +2,7 @@
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1998-2002 The R Development Core Team.
+ * Copyright (C) 2004 The R Foundation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -277,7 +278,7 @@ SEXP do_sort(SEXP call, SEXP op, SEXP args, SEXP rho)
/* faster versions of shellsort, following Sedgewick (1986) */
static const int incs[16] = {1073790977, 268460033, 67121153, 16783361, 4197377,
- 1050113, 262913, 65921, 16577, 4193, 1073, 281, 77,
+ 1050113, 262913, 65921, 16577, 4193, 1073, 281, 77,
23, 8, 1};
#define sort2_body \
@@ -732,6 +733,8 @@ SEXP do_rank(SEXP call, SEXP op, SEXP args, SEXP rho)
int *in;
double *rk;
int i, j, k, n;
+ char *ties_str;
+ enum {AVERAGE, MAX, MIN} ties_kind = AVERAGE;
checkArity(op, args);
if (args == R_NilValue)
@@ -743,6 +746,11 @@ SEXP do_rank(SEXP call, SEXP op, SEXP args, SEXP rho)
PROTECT(indx = allocVector(INTSXP, n));
PROTECT(rank = allocVector(REALSXP, n));
UNPROTECT(2);
+ ties_str = CHAR(STRING_ELT(coerceVector(CADR(args), STRSXP), 0));
+ if(!strcmp(ties_str, "average")) ties_kind = AVERAGE;
+ else if(!strcmp(ties_str, "max")) ties_kind = MAX;
+ else if(!strcmp(ties_str, "min")) ties_kind = MIN;
+ else error("invalid ties.method for rank() [should never happen]");
if (n > 0) {
in = INTEGER(indx);
rk = REAL(rank);
@@ -754,9 +762,16 @@ SEXP do_rank(SEXP call, SEXP op, SEXP args, SEXP rho)
j = i;
while ((j < n - 1) && equal(in[j], in[j + 1], x, TRUE))
j++;
- if (i != j) {
- for (k = i; k <= j; k++)
- rk[in[k]] = (i + j + 2) / 2.0;
+ if (i != j) { /* ties */
+ switch(ties_kind) {
+ case AVERAGE:
+ for (k = i; k <= j; k++)
+ rk[in[k]] = (i + j + 2) / 2.; break;
+ case MAX:
+ for (k = i; k <= j; k++) rk[in[k]] = j+1; break;
+ case MIN:
+ for (k = i; k <= j; k++) rk[in[k]] = i+1; break;
+ }
}
else
rk[in[i]] = i + 1;
@@ -811,7 +826,7 @@ SEXP do_radixsort(SEXP call, SEXP op, SEXP args, SEXP rho)
if(INTEGER(x)[i] == NA_INTEGER) cnts[napos]++;
else cnts[off+INTEGER(x)[i]]++;
}
-
+
for(i = 1; i <= xmax+1; i++) cnts[i] += cnts[i-1];
if(decreasing)
for(i = 0; i < n; i++){
Please sign in to comment.
Something went wrong with that request. Please try again.