diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index c3386eabf3a..1afe08a3a9e 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -124,12 +124,14 @@ of its previous imperfect workaround R code). \code{dput()}, \emph{etc} now print the \code{names()} information - only once, using the more readable \code{(tag = value)} syntax. - - These functions gain a new (partly experimental) control option - \emph{via} \code{.deparseOpts()}, \code{"niceNames"}, which when - set (e.g.\sspace{}as part of \code{"all"}) also use the \code{(tag - = value)} syntax for atomic vectors. + only once, using the more readable \code{(tag = value)} syntax, + notably for \code{list()}s, i.e., including data frames. + + These functions gain a new control option \code{"niceNames"} (see + \code{.deparseOpts()}), which when set (as by default) also uses + the \code{(tag = value)} syntax for atomic vectors. OTOH, without + deparse options \code{"showAttributes"} and \code{"niceNames"}, + names are no longer shown also for lists. \code{m:n} now also deparses nicely when \eqn{m > n}. diff --git a/src/include/Defn.h b/src/include/Defn.h index d1d863cf51c..c3b82772e93 100644 --- a/src/include/Defn.h +++ b/src/include/Defn.h @@ -1075,7 +1075,7 @@ void R_SetVarLocValue(R_varloc_t, SEXP); #define NICE_NAMES 1024 /* common combinations of the above */ #define SIMPLEDEPARSE 0 -#define DEFAULTDEPARSE 65 /* KEEPINTEGER | KEEPNA, used for calls */ +#define DEFAULTDEPARSE 1089 /* KEEPINTEGER | KEEPNA | NICE_NAMES, used for calls */ #define FORSOURCING 95 /* not DELAYPROMISES, used in edit.c */ /* Coercion functions */ diff --git a/src/library/base/R/New-Internal.R b/src/library/base/R/New-Internal.R index 9a9b3e1b1de..159dec7e56d 100644 --- a/src/library/base/R/New-Internal.R +++ b/src/library/base/R/New-Internal.R @@ -124,7 +124,7 @@ rbind <- function(..., deparse.level = 1) deparse <- function(expr, width.cutoff = 60L, backtick = mode(expr) %in% c("call", "expression", "(", "function"), - control = c("keepInteger", "showAttributes", "keepNA"), + control = c("keepNA", "keepInteger", "niceNames", "showAttributes"), nlines = -1L) .Internal(deparse(expr, width.cutoff, backtick, .deparseOpts(control), nlines)) diff --git a/src/library/base/R/dput.R b/src/library/base/R/dput.R index a37d9ed292f..8737737c925 100644 --- a/src/library/base/R/dput.R +++ b/src/library/base/R/dput.R @@ -17,8 +17,8 @@ # https://www.R-project.org/Licenses/ dput <- - function(x, file = "", - control = c("keepNA", "keepInteger", "showAttributes")) + function(x, file = "", ## keep in sync with deparse() ./New-Internal.R : + control = c("keepNA", "keepInteger", "niceNames", "showAttributes")) { if(is.character(file)) if(nzchar(file)) { diff --git a/src/library/base/man/deparse.Rd b/src/library/base/man/deparse.Rd index aa1d6086898..8fff3e2b11d 100644 --- a/src/library/base/man/deparse.Rd +++ b/src/library/base/man/deparse.Rd @@ -11,9 +11,8 @@ } \usage{ deparse(expr, width.cutoff = 60L, - backtick = mode(expr) \%in\% - c("call", "expression", "(", "function"), - control = c("keepInteger", "showAttributes", "keepNA"), + backtick = mode(expr) \%in\% c("call", "expression", "(", "function"), + control = c("keepNA", "keepInteger", "niceNames", "showAttributes"), nlines = -1L) } \arguments{ diff --git a/src/library/base/man/dput.Rd b/src/library/base/man/dput.Rd index 97542e2318b..e7a852adcca 100644 --- a/src/library/base/man/dput.Rd +++ b/src/library/base/man/dput.Rd @@ -1,6 +1,6 @@ % File src/library/base/man/dput.Rd % Part of the R package, https://www.R-project.org -% Copyright 1995-2014 R Core Team +% Copyright 1995-2017 R Core Team % Distributed under GPL 2 or later \name{dput} @@ -13,7 +13,7 @@ } \usage{ dput(x, file = "", - control = c("keepNA", "keepInteger", "showAttributes")) + control = c("keepNA", "keepInteger", "niceNames", "showAttributes")) dget(file, keep.source = FALSE) } @@ -60,7 +60,7 @@ dget(file, keep.source = FALSE) designed to be used for transporting \R data, and will work with \R objects that \code{dput} does not handle correctly as well as being much faster. - + To avoid the risk of a source attribute out of sync with the actual function definition, the source attribute of a function will never be written as an attribute. @@ -98,6 +98,12 @@ dput(xx, "foo", control = "digits17") dget("foo") - xx # slight rounding on some platforms dput(xx, "foo", control = "hexNumeric"); dget("foo") - xx unlink("foo") + +xn <- setNames(xx, paste0("pi^",1:3)) +dput(xn) # nicer, now "niceNames" being part of default 'control' +dput(xn, control = "S_compat") # no names +## explicitly asking for output as in R < 3.5.0: +dput(xn, control = c("keepNA", "keepInteger", "showAttributes")) } \keyword{file} \keyword{programming} diff --git a/src/library/utils/R/str.R b/src/library/utils/R/str.R index 9e9e808df90..a97ca1f7403 100644 --- a/src/library/utils/R/str.R +++ b/src/library/utils/R/str.R @@ -212,7 +212,7 @@ str.default <- has.class <- S4 || !is.null(cl) # S3 or S4 mod <- ""; char.like <- FALSE if(give.attr) a <- attributes(object)#-- save for later... - dCtrl <- eval(formals(deparse)$control) + dCtrl <- unique(c(eval(formals(deparse)$control), "niceNames")) if(drop.deparse.attr) dCtrl <- dCtrl[dCtrl != "showAttributes"] deParse <- function(.) deparse(., width.cutoff = min(500L, max(20L, width-10L)), control = dCtrl) diff --git a/src/main/deparse.c b/src/main/deparse.c index 6feaf6d87f3..7d47b37417c 100644 --- a/src/main/deparse.c +++ b/src/main/deparse.c @@ -141,10 +141,10 @@ static void deparse2buff(SEXP, LocalParseData *); static void print2buff(const char *, LocalParseData *); static void printtab2buff(int, LocalParseData *); static void writeline(LocalParseData *); +static void vec2buff (SEXP, LocalParseData *, Rboolean do_names); static void vector2buff(SEXP, LocalParseData *); static void src2buff1(SEXP, LocalParseData *); static Rboolean src2buff(SEXP, int, LocalParseData *); -static void vec2buff(SEXP, LocalParseData *); static void linebreak(Rboolean *lbreak, LocalParseData *); static void deparse2(SEXP, SEXP, LocalParseData *); @@ -590,39 +590,81 @@ static Rboolean needsparens(PPinfo mainop, SEXP arg, unsigned int left) return FALSE; } -/* check for attributes other than function source */ -static Rboolean hasAttributes(SEXP s, Rboolean except_names) +// does the character() vector x contain `NA_character_` ? +static Rboolean anyNA_chr(SEXP x) { - SEXP a = ATTRIB(s); - if (length(a) > (except_names ? 3 : 2)) return(TRUE); + if(TYPEOF(x) == STRSXP) { + R_xlen_t i, n = xlength(x); + for (i = 0; i < n; i++) { + if (STRING_ELT(x, i) == NA_STRING) + return TRUE; + } + } + return FALSE; +} + +typedef enum { SIMPLE = 0, + OK_NAMES, // no structure(*); names written as (n1 = v1, ..) + STRUC_ATTR, // use structure(*, = *, ..) for non-names only + STRUC_NMS_A // use structure(*, = *, ..) for names, too +} attr_type; + + +/* Does 's' have attributes other than function source, ok-names,.. + ==> using c(a= ., b=.) ... or structure(list(a=., ..), ) or ... + [ Currently only called in 1 place from attr1()] +*/ +static attr_type hasAttributes(SEXP s, Rboolean nice_names) +{ + SEXP a = ATTRIB(s), nm; +/* No longer: if (length(a) > (nice_names ? 3 : 2)) return(STRUC_ATTR); + as we need to distinguish STRUC_ATTR and STRUC_NMS_A + */ + nm = getAttrib(s, R_NamesSymbol); + Rboolean has_names = !isNull(nm), ok_names; + if(has_names) { + // ok only if there's no NA_character_ in names(.): + ok_names = nice_names && !anyNA_chr(nm); +#ifdef DEBUG_DEPARSE + REprintf("has_names=TRUE, ok_names = %s", ok_names ? "TRUE" : "FALSE"); +#endif + if(!ok_names) + return(STRUC_NMS_A); + } while(!isNull(a)) { - if(!((TAG(a) == R_SrcrefSymbol) || - (TAG(a) == R_NamesSymbol && except_names))) - return(TRUE); + if(has_names && TAG(a) == R_NamesSymbol) { + // also ok_names = TRUE + } else if(TAG(a) != R_SrcrefSymbol) + return(STRUC_ATTR); + // else a = CDR(a); } - return(FALSE); +#ifdef DEBUG_DEPARSE + REprintf(" before return (%s)\n", has_names ? "OK_NAMES" : "SIMPLE"); +#endif + return has_names ? OK_NAMES : SIMPLE; } -static Rboolean attr1(SEXP s, LocalParseData *d) +static attr_type attr1(SEXP s, LocalParseData *d) { - Rboolean ans = hasAttributes(s, /* except_names = */ d->opts & NICE_NAMES); - if(ans) + attr_type attr = hasAttributes(s, /* nice_names = */ d->opts & NICE_NAMES); + if(attr >= STRUC_ATTR) { +#ifdef DEBUG_DEPARSE + REprintf(" gave %s\n", (attr == STRUC_ATTR) ? "STRUC_ATTR" : "STRUC_NMS_A"); +#endif print2buff("structure(", d); - return ans; + } + return attr; } -static void attr2(SEXP s, LocalParseData *d) +static void attr2(SEXP s, LocalParseData *d, Rboolean not_names) { - int d_opts_in = d->opts, - nice_names = (d_opts_in & NICE_NAMES); - // not needed, as attr2() must be called only if(hasAttributes(.)) : /* if(hasAttributes(s, nice_names)) { */ SEXP a = ATTRIB(s); while(!isNull(a)) { if(TAG(a) != R_SrcrefSymbol && - (TAG(a) != R_NamesSymbol || !nice_names)) { + !(TAG(a) == R_NamesSymbol && not_names)) { print2buff(", ", d); if(TAG(a) == R_DimSymbol) { print2buff(".Dim", d); @@ -642,6 +684,7 @@ static void attr2(SEXP s, LocalParseData *d) else { /* TAG(a) might contain spaces etc */ const char *tag = CHAR(PRINTNAME(TAG(a))); + int d_opts_in = d->opts; d->opts = SIMPLEDEPARSE; /* turn off quote()ing */ if(isValidName(tag)) deparse2buff(TAG(a), d); @@ -691,7 +734,7 @@ static void printcomment(SEXP s, LocalParseData *d) } -static const char * quotify(SEXP name, int quote) +static const char *quotify(SEXP name, int quote) { const char *s = CHAR(name); @@ -742,12 +785,14 @@ static Rboolean parenthesizeCaller(SEXP s) #define SIMPLE_OPTS (~QUOTEEXPRESSIONS & ~SHOWATTRIBUTES & ~DELAYPROMISES) /* keep KEEPINTEGER | USESOURCE | KEEPNA | S_COMPAT, also WARNINCOMPLETE but that is not used below this point. */ +#define SHOW_ATTR_OR_NMS (SHOWATTRIBUTES | NICE_NAMES) static void deparse2buff(SEXP s, LocalParseData *d) { PPinfo fop; Rboolean lookahead = FALSE, lbreak = FALSE, parens, fnarg = d->fnarg, - outerparens, doquote, doAttr = TRUE; + outerparens, doquote; + attr_type attr = STRUC_ATTR; SEXP op, t; int d_opts_in = d->opts, i, n; @@ -764,7 +809,7 @@ static void deparse2buff(SEXP s, LocalParseData *d) case SYMSXP: doquote = (d_opts_in & QUOTEEXPRESSIONS) && strlen(CHAR(PRINTNAME(s))); if (doquote) { - doAttr = (d_opts_in & SHOWATTRIBUTES) ? attr1(s, d) : FALSE; + attr = (d_opts_in & SHOW_ATTR_OR_NMS) ? attr1(s, d) : SIMPLE; print2buff("quote(", d); } if (d_opts_in & S_COMPAT) { @@ -775,7 +820,7 @@ static void deparse2buff(SEXP s, LocalParseData *d) print2buff(CHAR(PRINTNAME(s)), d); if (doquote) { print2buff(")", d); - if(doAttr) attr2(s, d); + if(attr >= STRUC_ATTR) attr2(s, d, (attr == STRUC_ATTR)); } break; case CHARSXP: @@ -811,7 +856,7 @@ static void deparse2buff(SEXP s, LocalParseData *d) } break; case CLOSXP: - doAttr = (d_opts_in & SHOWATTRIBUTES) ? attr1(s, d) : FALSE; + attr = (d_opts_in & SHOW_ATTR_OR_NMS) ? attr1(s, d) : SIMPLE; if ((d->opts & USESOURCE) && !isNull(t = getAttrib(s, R_SrcrefSymbol))) src2buff1(t, d); @@ -827,41 +872,39 @@ static void deparse2buff(SEXP s, LocalParseData *d) deparse2buff(BODY_EXPR(s), d); d->opts = d_opts_in; } - if(doAttr) attr2(s, d); + if(attr >= STRUC_ATTR) attr2(s, d, (attr == STRUC_ATTR)); break; case ENVSXP: d->sourceable = FALSE; print2buff("", d); break; case VECSXP: - d->opts |= NICE_NAMES; // as vec2buf() already prints names nicely - doAttr = (d_opts_in & SHOWATTRIBUTES) ? attr1(s, d) : FALSE; + attr = (d_opts_in & SHOW_ATTR_OR_NMS) ? attr1(s, d) : SIMPLE; print2buff("list(", d); d->opts = d_opts_in;// vec2buff() must use unchanged d - vec2buff(s, d); + vec2buff(s, d, attr == OK_NAMES || attr == STRUC_ATTR); d->opts |= NICE_NAMES; print2buff(")", d); - if(doAttr) attr2(s, d); + if(attr >= STRUC_ATTR) attr2(s, d, (attr == STRUC_ATTR)); d->opts = d_opts_in; break; case EXPRSXP: - d->opts |= NICE_NAMES; // as vec2buf() already prints names nicely - doAttr = (d_opts_in & SHOWATTRIBUTES) ? attr1(s, d) : FALSE; + attr = (d_opts_in & SHOW_ATTR_OR_NMS) ? attr1(s, d) : SIMPLE; if(length(s) <= 0) print2buff("expression()", d); else { int locOpts = d->opts; print2buff("expression(", d); d->opts &= SIMPLE_OPTS; - vec2buff(s, d); + vec2buff(s, d, attr == OK_NAMES || attr == STRUC_ATTR); d->opts = locOpts; print2buff(")", d); } - if(doAttr) attr2(s, d); + if(attr >= STRUC_ATTR) attr2(s, d, (attr == STRUC_ATTR)); d->opts = d_opts_in; break; case LISTSXP: - doAttr = (d_opts_in & SHOWATTRIBUTES) ? attr1(s, d) : FALSE; + attr = (d_opts_in & SHOW_ATTR_OR_NMS) ? attr1(s, d) : SIMPLE; print2buff("pairlist(", d); d->inlist++; for (t=s ; CDR(t) != R_NilValue ; t=CDR(t) ) { @@ -883,7 +926,7 @@ static void deparse2buff(SEXP s, LocalParseData *d) deparse2buff(CAR(t), d); print2buff(")", d); d->inlist--; - if(doAttr) attr2(s, d); + if(attr >= STRUC_ATTR) attr2(s, d, (attr == STRUC_ATTR)); break; case LANGSXP: printcomment(s, d); @@ -902,18 +945,21 @@ static void deparse2buff(SEXP s, LocalParseData *d) s = CDR(s); if (userbinop) { if (isNull(getAttrib(s, R_NamesSymbol))) { - fop.kind = PP_BINARY2; /* not quite right for spacing, but can't be unary */ + // not quite right for spacing, but can't be unary : + fop.kind = PP_BINARY2; fop.precedence = PREC_PERCENT; fop.rightassoc = 0; } else - fop.kind = PP_FUNCALL; /* if args are named, deparse as function call (PR#15350) */ + // if args are named, deparse as function call (PR#15350): + fop.kind = PP_FUNCALL; } else fop = PPINFO(SYMVALUE(op)); if (fop.kind == PP_BINARY) { switch (length(s)) { case 1: fop.kind = PP_UNARY; - if (fop.precedence == PREC_SUM) /* binary +/- precedence upgraded as unary */ + if (fop.precedence == PREC_SUM) + // binary +/- precedence upgraded as unary fop.precedence = PREC_SIGN; break; case 2: @@ -1166,14 +1212,14 @@ static void deparse2buff(SEXP s, LocalParseData *d) } if ( isSymbol(CAR(s)) && TYPEOF(val) == CLOSXP - && streql(CHAR(PRINTNAME(CAR(s))), "::") ){ /* :: is special case */ + && streql(CHAR(PRINTNAME(CAR(s))), "::") ) { // :: is special case deparse2buff(CADR(s), d); print2buff("::", d); deparse2buff(CADDR(s), d); } else if ( isSymbol(CAR(s)) && TYPEOF(val) == CLOSXP - && streql(CHAR(PRINTNAME(CAR(s))), ":::") ){ /* ::: is special case */ + && streql(CHAR(PRINTNAME(CAR(s))), ":::") ) { // ::: is special case deparse2buff(CADR(s), d); print2buff(":::", d); deparse2buff(CADDR(s), d); @@ -1220,7 +1266,7 @@ static void deparse2buff(SEXP s, LocalParseData *d) d->opts = d_opts_in; print2buff(")", d); } - break; // case LANGSXP + break; // case LANGSXP -------------------------------------------------- case STRSXP: case LGLSXP: case INTSXP: @@ -1285,7 +1331,7 @@ static void deparse2buff(SEXP s, LocalParseData *d) R_do_slot(s, installTrChar(STRING_ELT(slotNms, i)))); } setAttrib(slotlist, R_NamesSymbol, slotNms); - vec2buff(slotlist, d); + vec2buff(slotlist, d, TRUE); /*-----------------*/ UNPROTECT(2); // (slotNms, slotlist) } @@ -1397,14 +1443,7 @@ static void vector2buff(SEXP vector, LocalParseData *d) int i, d_opts_in = d->opts, tlen = length(vector), quote = isString(vector) ? '"' : 0; - SEXP nv = R_NilValue; - Rboolean nice_names = d_opts_in & NICE_NAMES; - if(nice_names) { - nv = getAttrib(vector, R_NamesSymbol); - if (length(nv) == 0) nv = R_NilValue; - } Rboolean surround = FALSE, allNA, - need_c = (tlen > 1 || nv != R_NilValue), intSeq = FALSE; // := TRUE iff integer sequence 'm:n' (up *or* down) if(TYPEOF(vector) == INTSXP) { int *vec = INTEGER(vector), d_i; @@ -1420,15 +1459,28 @@ static void vector2buff(SEXP vector, LocalParseData *d) } } - Rboolean namesX = nice_names && (intSeq || tlen == 0); - if (namesX) // use structure(.,*) for names even if(nice_names) + SEXP nv = R_NilValue; + Rboolean do_names = (d_opts_in & SHOW_ATTR_OR_NMS); // iff TRUE use ' = ' + if(do_names) { + nv = getAttrib(vector, R_NamesSymbol); // only "do names" if have names: + if(isNull(nv)) + do_names = FALSE; + } + Rboolean + need_c = (tlen > 1 || !isNull(nv)), // (?) only TRUE iff SHOW_ATTR_OR_NMS + STR_names = do_names && (intSeq || tlen == 0); + if (STR_names) // use structure(.,*) for names even if(nice_names) d->opts &= ~NICE_NAMES; - Rboolean doAttr = (d_opts_in & SHOWATTRIBUTES) ? attr1(vector, d) : FALSE; + attr_type attr = (d_opts_in & SHOW_ATTR_OR_NMS) ? attr1(vector, d) : SIMPLE; + do_names = (attr == OK_NAMES || attr == STRUC_ATTR); if (tlen == 0) { #ifdef DEBUG_DEPARSE - REprintf("vector2buff(): namesX = %s, doAttr = %s\n", - namesX ? "TRUE" : "FALSE", - doAttr ? "TRUE" : "FALSE"); + REprintf("vector2buff(): (do_names, STR_names) = (%s,%s), attr = %s\n", + STR_names ? "TRUE" : "FALSE", + do_names? "TRUE" : "FALSE", + attr == STRUC_NMS_A ? "STRUC_NMS_A" : + (attr == STRUC_ATTR ? "STRUC_ATTR" : + (attr == OK_NAMES ? "OK_NAMES" : "SIMPLE"))); #endif switch(TYPEOF(vector)) { case LGLSXP: print2buff("logical(0)", d); break; @@ -1468,8 +1520,8 @@ static void vector2buff(SEXP vector, LocalParseData *d) allNA = allNA && !(d->opts & S_COMPAT); if(need_c) print2buff("c(", d); for (i = 0; i < tlen; i++) { - deparse2buf_name(nv, i, d); - + if(do_names) // put ' = ' + deparse2buf_name(nv, i, d); if(allNA && vec[i] == NA_INTEGER) { print2buff("NA_integer_", d); } else { @@ -1525,8 +1577,8 @@ static void vector2buff(SEXP vector, LocalParseData *d) if(need_c) print2buff("c(", d); allNA = allNA && !(d->opts & S_COMPAT); for (i = 0; i < tlen; i++) { - deparse2buf_name(nv, i, d); - + if(do_names) // put ' = ' + deparse2buf_name(nv, i, d); if(allNA && TYPEOF(vector) == REALSXP && ISNA(REAL(vector)[i])) { strp = "NA_real_"; @@ -1597,9 +1649,10 @@ static void vector2buff(SEXP vector, LocalParseData *d) if(need_c ) print2buff(")", d); if(surround) print2buff(")", d); } - if (doAttr) attr2(vector, d); - if (namesX) d->opts = d_opts_in; -} + if(attr >= STRUC_ATTR) attr2(vector, d, (attr == STRUC_ATTR)); + if (STR_names) d->opts = d_opts_in; +} // vector2buff() + /* src2buff1: Deparse one source ref to buffer */ @@ -1635,13 +1688,18 @@ static Rboolean src2buff(SEXP sv, int k, LocalParseData *d) /* Deparse vectors of S-expressions, i.e., list() and expression() objects. In particular, this deparses objects of mode expression. */ -static void vec2buff(SEXP v, LocalParseData *d) +static void vec2buff(SEXP v, LocalParseData *d, + Rboolean do_names) // iff TRUE use ' = ' { Rboolean lbreak = FALSE; const void *vmax = vmaxget(); int n = length(v); - SEXP nv = getAttrib(v, R_NamesSymbol); - if (length(nv) == 0) nv = R_NilValue; + SEXP nv; + if(do_names) { + nv = getAttrib(v, R_NamesSymbol); // only "do names" if have names: + if (isNull(nv)) + do_names = FALSE; + } SEXP sv; // Srcref or NULL if (d->opts & USESOURCE) { @@ -1655,7 +1713,8 @@ static void vec2buff(SEXP v, LocalParseData *d) if (i > 0) print2buff(", ", d); linebreak(&lbreak, d); - deparse2buf_name(nv, i, d); + if(do_names) // put ' = ' + deparse2buf_name(nv, i, d); if (!src2buff(sv, i, d)) deparse2buff(VECTOR_ELT(v, i), d); } diff --git a/tests/Examples/datasets-Ex.Rout.save b/tests/Examples/datasets-Ex.Rout.save index 9822721533f..93410613648 100644 --- a/tests/Examples/datasets-Ex.Rout.save +++ b/tests/Examples/datasets-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2017-10-29 r73639) -- "Unsuffered Consequences" +R Under development (unstable) (2017-11-09 r73692) -- "Unsuffered Consequences" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) @@ -1034,7 +1034,7 @@ Variances: > boxplot(weight ~ group, data = PlantGrowth, main = "PlantGrowth data", + ylab = "Dried weight of plants", col = "lightgray", + notch = TRUE, varwidth = TRUE) -Warning in bxp(list(stats = c(4.17, 4.53, 5.155, 5.33, 6.11, 3.59, 4.17, : +Warning in bxp(list(stats = structure(c(4.17, 4.53, 5.155, 5.33, 6.11, 3.59, : some notches went outside hinges ('box'): maybe set notch=FALSE > anova(lm(weight ~ group, data = PlantGrowth)) Analysis of Variance Table @@ -1964,7 +1964,7 @@ Model 4: dist ~ poly(speed, degree) > boxplot(weight ~ feed, data = chickwts, col = "lightgray", + varwidth = TRUE, notch = TRUE, main = "chickwt data", + ylab = "Weight at six weeks (gm)") -Warning in bxp(list(stats = c(216, 271.5, 342, 373.5, 404, 108, 136, 151.5, : +Warning in bxp(list(stats = structure(c(216, 271.5, 342, 373.5, 404, 108, : some notches went outside hinges ('box'): maybe set notch=FALSE > anova(fm1 <- lm(weight ~ feed, data = chickwts)) Analysis of Variance Table diff --git a/tests/Examples/graphics-Ex.Rout.save b/tests/Examples/graphics-Ex.Rout.save index ae225330843..780f6f7ff4a 100644 --- a/tests/Examples/graphics-Ex.Rout.save +++ b/tests/Examples/graphics-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2017-10-29 r73639) -- "Unsuffered Consequences" +R Under development (unstable) (2017-11-09 r73692) -- "Unsuffered Consequences" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) @@ -373,7 +373,7 @@ Hair Brown Blue Hazel Green > # *add* notches (somewhat funny here): > boxplot(count ~ spray, data = InsectSprays, + notch = TRUE, add = TRUE, col = "blue") -Warning in bxp(list(stats = c(7, 11, 14, 18.5, 23, 7, 12, 16.5, 18, 21, : +Warning in bxp(list(stats = structure(c(7, 11, 14, 18.5, 23, 7, 12, 16.5, : some notches went outside hinges ('box'): maybe set notch=FALSE > > boxplot(decrease ~ treatment, data = OrchardSprays, diff --git a/tests/Examples/splines-Ex.Rout.save b/tests/Examples/splines-Ex.Rout.save index 69d814ee5cb..7a375e73892 100644 --- a/tests/Examples/splines-Ex.Rout.save +++ b/tests/Examples/splines-Ex.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2017-10-29 r73639) -- "Unsuffered Consequences" +R Under development (unstable) (2017-11-09 r73692) -- "Unsuffered Consequences" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) @@ -149,7 +149,7 @@ F-statistic: 1.298e+04 on 5 and 9 DF, p-value: < 2.2e-16 > plot(women, xlab = "Height (in)", ylab = "Weight (lb)") > ht <- seq(57, 73, length.out = 200) > lines(ht, predict(fm1, data.frame(height = ht))) -Warning in bs(height, degree = 3L, knots = c(62.6666666666667, 67.3333333333333 : +Warning in bs(height, degree = 3L, knots = c(`33.33333%` = 62.6666666666667, : some 'x' values beyond boundary knots may cause ill-conditioned bases > ## Don't show: > ## Consistency: @@ -256,8 +256,8 @@ F-statistic: 9609 on 5 and 9 DF, p-value: < 2.2e-16 > > ## To see what knots were selected > attr(terms(fm1), "predvars") -list(weight, ns(height, knots = c(60.8, 63.6, 66.4, 69.2), Boundary.knots = c(58, -72), intercept = FALSE)) +list(weight, ns(height, knots = c(`20%` = 60.8, `40%` = 63.6, +`60%` = 66.4, `80%` = 69.2), Boundary.knots = c(58, 72), intercept = FALSE)) > > ## example of safe prediction > plot(women, xlab = "Height (in)", ylab = "Weight (lb)") @@ -582,7 +582,7 @@ attr(,"class") > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.213 0.009 0.223 0 0 +Time elapsed: 0.155 0.012 0.199 0 0 > grDevices::dev.off() null device 1 diff --git a/tests/Examples/stats-Ex.Rout.save b/tests/Examples/stats-Ex.Rout.save index edb5cd2082d..84c66d59461 100644 --- a/tests/Examples/stats-Ex.Rout.save +++ b/tests/Examples/stats-Ex.Rout.save @@ -16156,10 +16156,11 @@ Step function with continuity 'f'= 0.2 , 3 knots at > > ## look at the internal structure: > unclass(sfun0) -function (v) -.approxfun(x, y, v, method, yleft, yright, f) - - +structure(function (v) +.approxfun(x, y, v, method, yleft, yright, f), call = stepfun(1:3, + y0, f = 0)) + + attr(,"call") stepfun(1:3, y0, f = 0) > ls(envir = environment(sfun0)) @@ -18483,7 +18484,7 @@ Number of Fisher Scoring iterations: 6 > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 6.568 0.139 6.872 0 0 +Time elapsed: 5.321 0.284 5.81 0 0 > grDevices::dev.off() null device 1 diff --git a/tests/eval-etc.R b/tests/eval-etc.R index c6fc41258c9..f64e03d5069 100644 --- a/tests/eval-etc.R +++ b/tests/eval-etc.R @@ -160,6 +160,8 @@ pd0 <- function(expr, backtick = TRUE, id_epd <- function(expr, control = c("all","digits17"), ...) eval(pd0(expr, control=control, ...)) dPut <- function(x, control = c("all","digits17")) dput(x, control=control) +##' Does 'x' contain "real" numbers +##' with > 3 digits after "." where deparse may be platform dependent? hasReal <- function(x) { if(is.double(x) || is.complex(x)) !all((x == round(x, 3)) | is.na(x)) @@ -177,14 +179,23 @@ hasReal <- function(x) { else FALSE } isMissObj <- function(obj) identical(obj, alist(a=)[[1]]) +##' Does 'obj' contain "the missing object" ? +##' @note defined recursively! +hasMissObj <- function(obj) { + if(is.recursive(obj)) { + if(is.function(obj) || is.language(obj)) + FALSE + else # incl pairlist()s + any(vapply(obj, hasMissObj, NA)) + } else isMissObj(obj) +} check_EPD <- function(obj, show = !hasReal(obj), eq.tol = if(.Machine$sizeof.longdouble <= 8) # no long-double 2*.Machine$double.eps else 0) { if(show) dPut(obj) - if(is.environment(obj) || - (is.pairlist(obj) && any(vapply(obj, isMissObj, NA)))) - { - cat("__ not parse()able __\n") + if(is.environment(obj) || hasMissObj(obj)) { + cat("__ not parse()able __:", + if(is.environment(obj)) "environment" else "hasMissObj(.) is true", "\n") return(invisible(obj)) # cannot parse it } ob2 <- id_epd(obj) @@ -225,6 +236,10 @@ i6 <- setNames(5:6, letters[5:6]) L4 <- list(ii = 5:2) # not named L6 <- list(L = i6) L6a <- list(L = structure(rev(i6), myDoc = "info")) +## these must use structure() to keep NA_character_ name: +LNA <- setNames(as.list(c(1,2,99)), c("A", "NA", NA)) +iNA <- unlist(LNA) +missL <- setNames(rep(list(alist(.=)$.), 3), c("",NA,"c")) ## empty *named* atomic vectors i00 <- setNames(integer(), character()); i0 <- structure(i00, foo = "bar") L00 <- setNames(logical(), character()); L0 <- structure(L00, class = "Logi") @@ -232,7 +247,8 @@ r00 <- setNames(raw(), character()) sii <- structure(4:7, foo = list(B="bar", G="grizzly", vec=c(a=1L,b=2L), v2=i6, v0=L00)) -## Creating a collection of S4 objects, ensuring deparse <-> parse are inverses +if(getRversion() >= "3.5.0") { + ## Creating a collection of S4 objects, ensuring deparse <-> parse are inverses library(methods) example(new) # creating t1 & t2 at least if(require("Matrix")) { cat("Trying some Matrix objects, too\n") @@ -266,7 +282,9 @@ if(require("Matrix")) { cat("Trying some Matrix objects, too\n") sy <- sparseMatrix(i= c(2,4,3:5), j= c(4,7:5,5), x = 1:5, dims = c(7,7), symmetric=TRUE) } +}# S4 deparse()ing only since R 3.5.0 +## Action! Check deparse <--> parse consistency for *all* objects: for(nm in ls(env=.GlobalEnv)) { cat(nm,": ", sep="") ## if(!any(nm == "r1")) ## 'r1' fails diff --git a/tests/eval-etc.Rout.save b/tests/eval-etc.Rout.save index 3bbb5a569be..3a260cb8806 100644 --- a/tests/eval-etc.Rout.save +++ b/tests/eval-etc.Rout.save @@ -1,5 +1,5 @@ -R Under development (unstable) (2017-10-29 r73639) -- "Unsuffered Consequences" +R Under development (unstable) (2017-11-09 r73692) -- "Unsuffered Consequences" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) @@ -217,6 +217,8 @@ Levels: a b > id_epd <- function(expr, control = c("all","digits17"), ...) + eval(pd0(expr, control=control, ...)) > dPut <- function(x, control = c("all","digits17")) dput(x, control=control) +> ##' Does 'x' contain "real" numbers +> ##' with > 3 digits after "." where deparse may be platform dependent? > hasReal <- function(x) { + if(is.double(x) || is.complex(x)) + !all((x == round(x, 3)) | is.na(x)) @@ -234,14 +236,23 @@ Levels: a b + else FALSE + } > isMissObj <- function(obj) identical(obj, alist(a=)[[1]]) +> ##' Does 'obj' contain "the missing object" ? +> ##' @note defined recursively! +> hasMissObj <- function(obj) { ++ if(is.recursive(obj)) { ++ if(is.function(obj) || is.language(obj)) ++ FALSE ++ else # incl pairlist()s ++ any(vapply(obj, hasMissObj, NA)) ++ } else isMissObj(obj) ++ } > check_EPD <- function(obj, show = !hasReal(obj), + eq.tol = if(.Machine$sizeof.longdouble <= 8) # no long-double + 2*.Machine$double.eps else 0) { + if(show) dPut(obj) -+ if(is.environment(obj) || -+ (is.pairlist(obj) && any(vapply(obj, isMissObj, NA)))) -+ { -+ cat("__ not parse()able __\n") ++ if(is.environment(obj) || hasMissObj(obj)) { ++ cat("__ not parse()able __:", ++ if(is.environment(obj)) "environment" else "hasMissObj(.) is true", "\n") + return(invisible(obj)) # cannot parse it + } + ob2 <- id_epd(obj) @@ -282,6 +293,10 @@ Levels: a b > L4 <- list(ii = 5:2) # not named > L6 <- list(L = i6) > L6a <- list(L = structure(rev(i6), myDoc = "info")) +> ## these must use structure() to keep NA_character_ name: +> LNA <- setNames(as.list(c(1,2,99)), c("A", "NA", NA)) +> iNA <- unlist(LNA) +> missL <- setNames(rep(list(alist(.=)$.), 3), c("",NA,"c")) > ## empty *named* atomic vectors > i00 <- setNames(integer(), character()); i0 <- structure(i00, foo = "bar") > L00 <- setNames(logical(), character()); L0 <- structure(L00, class = "Logi") @@ -289,9 +304,42 @@ Levels: a b > sii <- structure(4:7, foo = list(B="bar", G="grizzly", + vec=c(a=1L,b=2L), v2=i6, v0=L00)) > -> ## Creating a collection of S4 objects, ensuring deparse <-> parse are inverses -> library(methods) -> example(new) # creating t1 & t2 at least +> if(getRversion() >= "3.5.0") { ++ ## Creating a collection of S4 objects, ensuring deparse <-> parse are inverses ++ library(methods) ++ example(new) # creating t1 & t2 at least ++ if(require("Matrix")) { cat("Trying some Matrix objects, too\n") ++ D5. <- Diagonal(x = 5:1) ++ D5N <- D5.; D5N[5,5] <- NA ++ example(Matrix) ++ ## a subset from example(sparseMatrix) : ++ i <- c(1,3:8); j <- c(2,9,6:10); x <- 7 * (1:7) ++ A <- sparseMatrix(i, j, x = x) ++ sA <- sparseMatrix(i, j, x = x, symmetric = TRUE) ++ tA <- sparseMatrix(i, j, x = x, triangular= TRUE) ++ ## dims can be larger than the maximum row or column indices ++ AA <- sparseMatrix(c(1,3:8), c(2,9,6:10), x = 7 * (1:7), dims = c(10,20)) ++ ## i, j and x can be in an arbitrary order, as long as they are consistent ++ set.seed(1); (perm <- sample(1:7)) ++ A1 <- sparseMatrix(i[perm], j[perm], x = x[perm]) ++ ## the (i,j) pairs can be repeated, in which case the x's are summed ++ args <- data.frame(i = c(i, 1), j = c(j, 2), x = c(x, 2)) ++ Aa <- do.call(sparseMatrix, args) ++ A. <- do.call(sparseMatrix, c(args, list(use.last.ij = TRUE))) ++ ## for a pattern matrix, of course there is no "summing": ++ nA <- do.call(sparseMatrix, args[c("i","j")]) ++ dn <- list(LETTERS[1:3], letters[1:5]) ++ ## pointer vectors can be used, and the (i,x) slots are sorted if necessary: ++ m <- sparseMatrix(i = c(3,1, 3:2, 2:1), p= c(0:2, 4,4,6), x = 1:6, dimnames = dn) ++ ## no 'x' --> patter*n* matrix: ++ n <- sparseMatrix(i=1:6, j=rev(2:7)) ++ ## an empty sparse matrix: ++ e <- sparseMatrix(dims = c(4,6), i={}, j={}) ++ ## a symmetric one: ++ sy <- sparseMatrix(i= c(2,4,3:5), j= c(4,7:5,5), x = 1:5, ++ dims = c(7,7), symmetric=TRUE) ++ } ++ }# S4 deparse()ing only since R 3.5.0 new> ## using the definition of class "track" from setClass new> @@ -345,37 +393,6 @@ new> ## End(Don't show) new> new> new> -> if(require("Matrix")) { cat("Trying some Matrix objects, too\n") -+ D5. <- Diagonal(x = 5:1) -+ D5N <- D5.; D5N[5,5] <- NA -+ example(Matrix) -+ ## a subset from example(sparseMatrix) : -+ i <- c(1,3:8); j <- c(2,9,6:10); x <- 7 * (1:7) -+ A <- sparseMatrix(i, j, x = x) -+ sA <- sparseMatrix(i, j, x = x, symmetric = TRUE) -+ tA <- sparseMatrix(i, j, x = x, triangular= TRUE) -+ ## dims can be larger than the maximum row or column indices -+ AA <- sparseMatrix(c(1,3:8), c(2,9,6:10), x = 7 * (1:7), dims = c(10,20)) -+ ## i, j and x can be in an arbitrary order, as long as they are consistent -+ set.seed(1); (perm <- sample(1:7)) -+ A1 <- sparseMatrix(i[perm], j[perm], x = x[perm]) -+ ## the (i,j) pairs can be repeated, in which case the x's are summed -+ args <- data.frame(i = c(i, 1), j = c(j, 2), x = c(x, 2)) -+ Aa <- do.call(sparseMatrix, args) -+ A. <- do.call(sparseMatrix, c(args, list(use.last.ij = TRUE))) -+ ## for a pattern matrix, of course there is no "summing": -+ nA <- do.call(sparseMatrix, args[c("i","j")]) -+ dn <- list(LETTERS[1:3], letters[1:5]) -+ ## pointer vectors can be used, and the (i,x) slots are sorted if necessary: -+ m <- sparseMatrix(i = c(3,1, 3:2, 2:1), p= c(0:2, 4,4,6), x = 1:6, dimnames = dn) -+ ## no 'x' --> patter*n* matrix: -+ n <- sparseMatrix(i=1:6, j=rev(2:7)) -+ ## an empty sparse matrix: -+ e <- sparseMatrix(dims = c(4,6), i={}, j={}) -+ ## a symmetric one: -+ sy <- sparseMatrix(i= c(2,4,3:5), j= c(4,7:5,5), x = 1:5, -+ dims = c(7,7), symmetric=TRUE) -+ } Loading required package: Matrix Trying some Matrix objects, too @@ -513,6 +530,7 @@ Matrix> stopifnot(is(As, "symmetricMatrix"), Matrix+ is(Matrix(0, 3,3), "sparseMatrix"), Matrix+ is(Matrix(FALSE, 1,1), "sparseMatrix")) > +> ## Action! Check deparse <--> parse consistency for *all* objects: > for(nm in ls(env=.GlobalEnv)) { + cat(nm,": ", sep="") + ## if(!any(nm == "r1")) ## 'r1' fails @@ -567,7 +585,7 @@ quote(match.call()) --> checking list(*): Ok checking formals(.): pairlist(... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- CO: function (..., file = NULL, append = FALSE, type = c("output", "message"), split = FALSE) @@ -659,7 +677,7 @@ quote({ checking formals(.): pairlist(... = , file = NULL, append = FALSE, type = quote(c("output", "message")), split = FALSE) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- D5.: new("ddiMatrix", diag = "N", Dim = c(5L, 5L), Dimnames = list( @@ -679,7 +697,7 @@ quote(CC(...)) --> checking list(*): Ok checking formals(.): pairlist(... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- I3: new("ddiMatrix", diag = "U", Dim = c(3L, 3L), Dimnames = list( @@ -707,6 +725,9 @@ L6: list(L = structure(5:6, .Names = c("e", "f"))) L6a: list(L = structure(6:5, .Names = c("f", "e"), myDoc = "info")) --> checking list(*): Ok --=--=--=--=-- +LNA: structure(list(1, 2, 99), .Names = c("A", "NA", NA)) + --> checking list(*): Ok +--=--=--=--=-- M: new("ltCMatrix", i = c(0L, 0L, 1L), p = c(0L, 0L, 1L, 3L), Dim = c(3L, 3L), Dimnames = list(NULL, NULL), x = c(TRUE, TRUE, TRUE), uplo = "U", @@ -767,9 +788,10 @@ check_EPD: function (obj, show = !hasReal(obj), eq.tol = if (.Machine$sizeof.lon { if (show) dPut(obj) - if (is.environment(obj) || (is.pairlist(obj) && any(vapply(obj, - isMissObj, NA)))) { - cat("__ not parse()able __\n") + if (is.environment(obj) || hasMissObj(obj)) { + cat("__ not parse()able __:", if (is.environment(obj)) + "environment" + else "hasMissObj(.) is true", "\n") return(invisible(obj)) } ob2 <- id_epd(obj) @@ -802,9 +824,10 @@ checking body(.): quote({ if (show) dPut(obj) - if (is.environment(obj) || (is.pairlist(obj) && any(vapply(obj, - isMissObj, NA)))) { - cat("__ not parse()able __\n") + if (is.environment(obj) || hasMissObj(obj)) { + cat("__ not parse()able __:", if (is.environment(obj)) + "environment" + else "hasMissObj(.) is true", "\n") return(invisible(obj)) } ob2 <- id_epd(obj) @@ -836,7 +859,7 @@ quote({ checking formals(.): pairlist(obj = , show = quote(!hasReal(obj)), eq.tol = quote(if (.Machine$sizeof.longdouble <= 8) 2 * .Machine$double.eps else 0)) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- dPut: function (x, control = c("all", "digits17")) dput(x, control = control) @@ -846,7 +869,7 @@ quote(dput(x, control = control)) --> checking list(*): Ok checking formals(.): pairlist(x = , control = quote(c("all", "digits17"))) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- dn: list(c("A", "B", "C"), c("a", "b", "c", "d", "e")) --> checking list(*): Ok @@ -874,7 +897,7 @@ quote(substitute(list(x, ...))) --> checking list(*): Ok checking formals(.): pairlist(x = , ... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- fx: structure(c(1L, 3L, 2L), .Label = c("a", "b", NA), class = "factor") --> checking list(*): Ok @@ -887,7 +910,7 @@ quote(h(f(...))) --> checking list(*): Ok checking formals(.): pairlist(... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- h: function (...) list(...) @@ -897,7 +920,31 @@ quote(list(...)) --> checking list(*): Ok checking formals(.): pairlist(... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true +--=--=--=--=-- +hasMissObj: function (obj) +{ + if (is.recursive(obj)) { + if (is.function(obj) || is.language(obj)) + FALSE + else any(vapply(obj, hasMissObj, NA)) + } + else isMissObj(obj) +} + --> checking list(*): Ok +checking body(.): +quote({ + if (is.recursive(obj)) { + if (is.function(obj) || is.language(obj)) + FALSE + else any(vapply(obj, hasMissObj, NA)) + } + else isMissObj(obj) +}) + --> checking list(*): Ok +checking formals(.): +pairlist(obj = ) +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- hasReal: function (x) { @@ -935,7 +982,7 @@ quote({ --> checking list(*): Ok checking formals(.): pairlist(x = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- i: c(1, 3, 4, 5, 6, 7, 8) --> checking list(*): Ok @@ -949,6 +996,9 @@ i00: structure(integer(0), .Names = character(0)) i6: structure(5:6, .Names = c("e", "f")) --> checking list(*): Ok --=--=--=--=-- +iNA: structure(c(1, 2, 99), .Names = c("A", "NA", NA)) + --> checking list(*): Ok +--=--=--=--=-- id_epd: function (expr, control = c("all", "digits17"), ...) eval(pd0(expr, control = control, ...)) --> checking list(*): Ok @@ -957,7 +1007,7 @@ quote(eval(pd0(expr, control = control, ...))) --> checking list(*): Ok checking formals(.): pairlist(expr = , control = quote(c("all", "digits17")), ... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- isMissObj: function (obj) identical(obj, alist(a = )[[1]]) @@ -967,7 +1017,7 @@ quote(identical(obj, alist(a = )[[1]])) --> checking list(*): Ok checking formals(.): pairlist(obj = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- j: c(2, 9, 6, 7, 8, 9, 10) --> checking list(*): Ok @@ -980,7 +1030,7 @@ quote(g(...)) --> checking list(*): Ok checking formals(.): pairlist(... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- l3: structure(c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE), .Dim = c(3L, 3L)) @@ -992,6 +1042,9 @@ i = c(2L, 0L, 1L, 2L, 0L, 1L), p = c(0L, 1L, "C"), c("a", "b", "c", "d", "e")), x = c(1, 2, 4, 3, 6, 5), factors = list()) --> checking list(*): Ok --=--=--=--=-- +missL: structure(list(, , ), .Names = c("", NA, "c")) +__ not parse()able __: hasMissObj(.) is true +--=--=--=--=-- mycaller: function (x = 1, callme = pi) { callme(x) @@ -1032,7 +1085,7 @@ quote(parse(text = deparse(expr, backtick = backtick, control = control, checking formals(.): pairlist(expr = , backtick = TRUE, control = quote(c("keepInteger", "showAttributes", "keepNA")), ... = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- perm: c(2L, 3L, 6L, 4L, 1L, 7L, 5L) --> checking list(*): Ok @@ -1128,7 +1181,7 @@ quote({ --> checking list(*): Ok checking formals(.): pairlist(x = ) -__ not parse()able __ +__ not parse()able __: hasMissObj(.) is true --=--=--=--=-- u: --> checking list(*): Ok --=--=--=--=-- diff --git a/tests/reg-tests-2.Rout.save b/tests/reg-tests-2.Rout.save index ebd92dbf085..3c2af179da5 100644 --- a/tests/reg-tests-2.Rout.save +++ b/tests/reg-tests-2.Rout.save @@ -5708,16 +5708,14 @@ $y + i = as.character(NA), j = c("foo", NA, "bar") + ) > dput(x, control=NULL) -list(a = NA, b = NA, c = NA, d = NA, e = 1, f = 1, g = 1:3, h = c(NA, -1, 2, 3), i = NA, j = c("foo", NA, "bar")) +list(NA, NA, NA, NA, 1, 1, 1:3, c(NA, 1, 2, 3), NA, c("foo", +NA, "bar")) > dput(x, control="keepInteger") -list(a = NA, b = NA_integer_, c = NA, d = NA, e = 1, f = 1L, - g = 1:3, h = c(NA, 1L, 2L, 3L), i = NA, j = c("foo", NA, - "bar")) +list(NA, NA_integer_, NA, NA, 1, 1L, 1:3, c(NA, 1L, 2L, 3L), + NA, c("foo", NA, "bar")) > dput(x, control="keepNA") -list(a = NA, b = NA_integer_, c = NA_real_, d = NA_complex_, - e = 1, f = 1, g = 1:3, h = c(NA, 1, 2, 3), i = NA_character_, - j = c("foo", NA, "bar")) +list(NA, NA_integer_, NA_real_, NA_complex_, 1, 1, 1:3, c(NA, +1, 2, 3), NA_character_, c("foo", NA, "bar")) > dput(x) list(a = NA, b = NA_integer_, c = NA_real_, d = NA_complex_, e = 1, f = 1L, g = 1:3, h = c(NA, 1L, 2L, 3L), i = NA_character_, @@ -6226,7 +6224,7 @@ uY -2.1396554 0.3644116 > x <- data.frame(a=1:3, b=2:4) > x[,3] <- x Warning message: -In `[<-.data.frame`(`*tmp*`, , 3, value = list(a = 1:3, b = 2:4)) : +In `[<-.data.frame`(`*tmp*`, , 3, value = structure(list(a = 1:3, : provided 2 variables to replace 1 variables > x a b a.1 @@ -6398,9 +6396,10 @@ attr(,"yada") function () "not the same" > print(f, useSource = FALSE) # must print attributes -function () +structure(function () { -} +}, note = "just a note", yada = function () +"not the same") attr(,"note") [1] "just a note" attr(,"yada")