Nya funktioner i R-version 3.4.0

Nya funktioner i R-version 3.4.0

R Senaste versionerna innehåller följande nya funktioner

  • User errors such as integrate(f, 0:1, 2)Nu fångas.
  • Add signatureargument to debug(), debugonce(), undebug() and isdebugged() for more conveniently debugging S3 and S4 methods. (Baserat på en lapp från Gabe Becker.)
  • Add utils::debugcall()and utils::undebugcall() for debugging the function that would be called by evaluating the given expression. När samtalet är att en S4 generisk eller standard S3 generic, debugcall() debugs the method that would be dispatched. Ett antal interna verktyg tillsattes för att stödja denna, most notably utils::isS3stdGeneric(). (Baserat på en lapp från Gabe Becker.)
  • Add utils::strcapture(). Givet ett tecken vektor och ett reguljärt uttryck som innehåller fånga uttryck, strcapture()will extract the captured tokens into a tabular data structure, typically a frame.
  • str()and strOptions() get a new option deparse.attr with improved but changed default behaviour for expressions. For expression objects x, str(x) now may remove extraneous white space and truncate long lines.
  • str(<looooooooong_string>)is no longer very slow; inspired by Mikko Korpela’s proposal in PR#16527.
  • str(x)‘s default method is more “accurate” and hence somewhat more generous in displaying character vectors; this will occasionally change Routputs (and need changes to some ‘*.Rout(.save)’ files).
    For a classed integer vector such as x <- xtabs(~ c(1,9,9,9)), str(x) now shows both the class andint”, instead of only the latter.
  • isSymmetric(m)is much faster for large asymmetric matrices m via pre-tests and a new option tol1 (with which strict back compatibility is possible but not the default).
  • The result of eigen()now is of classeigenin the default case when eigenvectors are computed.
  • Zero-length date and date-time objects (of classesPOSIX[cl]?t”) now print()“recognizably”.
  • coords()and xyz.coords() get a new setLab option.
  • The methodargument of list(), order() and sort.int() gains anautooption (the default) which should behave the same as before when method was not supplied.
  • stopifnot(E, ..)now reports differences when E is a call to equal() and that is not true.
  • boxplot(<formula>, *)gain optional arguments drop, sep, and order to pass to split.default() which itself gains an argument lex.order to pass to interaction() for more flexibility.
  • The plot()method for ppr() has enhanced default labels (xmin and main).
  • int()gains an explicit useHash option (with a back compatible default).
  • identical()gains an srcref option which dropssrcrefand similar attributes when true (as by default).
  • diag(x, nrow = n)now preserves typeof(x), also for logical, integer and raw x (and as previously for complex and numeric).
  • spline()now allows direct specification of lambda, gets a hatvalues() method and keeps tol in the result, and optionally parts of the internal matrix computations.
  • addNA()is faster now, t.ex.. when applied twice. (Part of PR#16895.)
  • New option rstandard(<lm>, type =predicted”)provides the “PRESS”–related leave-one-out cross-validation errors for linear models.
  • After seven years of deprecation, duplicated factor levels now produce a warning when printed and an error in levels<-instead of a warning.
  • Invalid factors, e.g., with duplicated levels (invalid but constructable) now give a warning when printed, vianew function .valid.factor().
  • sessionInfo()has been updated for Apple’s change in OS naming as from ‘10.12’ (‘macOS Sierra’ vs ‘OS X El Capitan’).

Its toLatex() method now includes the running component.

  • options(avbrotts =)kan användas för att ange en standardåtgärd för användar avbrott. Tills vidare, if this option is not set and the error option is set, then an unhandled user interrupt invokes the error (This may be dropped in the future as interrupt conditions are not error conditions.)
  • In most cases user interrupt handlers will be called with a “återuppta”omstart tillgängligt. Hanterare kan åberopa denna omstart för att återuppta beräkning. At the browser prompt the r command will invoke a “återuppta” restart if one is available. Some read operations cannot be resumed properly when interrupted and do not provide a “återuppta”
  • Radix sort is now chosen by method =autofor int() for double vectors (and hence used for sort() for unclassed double vectors), excluding ‘long’ vectors.

sort.int(method =radix”) no longer rounds double vectors.

  • The defaultand frame methods for stack() preserve the names of empty elements in the levels of the ind column of the return value. Set the new drop argument to TRUE for the previous behavior.
  • Speedup in simplify2array()and hence sapply() and mapply() (for the case of names and common length > 1), thanks to Suharto Anggono’s PR#17118.
  • table(x, exclude = NULL)now sets useNA =ifany” (instead ofalways”). Together with the bug fixes for this case, this recovers more consistent behaviour compatible to older versions of R. As a consequence, summary() for a logical vector no longer reports (zero) counts for NA when there are no NA
  • frames()gets a new option include.GlobalEnv which allows to also dump the global environment, t
  • time()now uses message() instead of cat() when terminated early, such that suppressMessages() has an effect;
  • citation()supports ‘inst/CITATION’ files from package source trees, with loc pointing to the directory containing the package.
  • try()gains a new argument outFile with a default that can be modified via options(try.outFile = .), useful notably for Sweave.
  • The unexported low-level functions in package parallel for passing serialized Robjects to and from forked children now support long vectors on 64-bit platforms. This removes some limits on higher-level functions such as mclapply() (but returning gigabyte results from forked processes via serialization should be avoided if at all possible).
  • Connections now print()without error even if invalid, t.ex.. after having been destroyed.
  • apropos()and find(simple.words = FALSE) no longer match object names starting with . which are known to be internal objects (such as .__S3MethodsTable__.).
  • Convenience function hasName()has been added; it is intended to replace the common idiom !is.null(x$name) without the usually unintended partial name matching.
  • strcapture()no longer fixes column names nor coerces strings to factors (
  • strcapture()returns NA for non-matching values in x (
  • source()gets new optional arguments, notably exprs; this is made use of in the new utility function withAutoprint().
  • source()gets a new toplevel.env argument. This argument is useful for frameworks running package tests; c
  • setFileTime()and file.copy(copy.date = TRUE) will set timestamps with fractions of seconds on platforms/filesystems which support this.
  • (Windows only.) info()now returns file timestamps including fractions of seconds; it has done so on other platforms since R 2.14.0. (NB: some filesystems do not record modification and access timestamps to sub-second resolution.)
  • The license check enabled by options(checkPackageLicense = TRUE)is now done when the package’s namespace is first loaded.
  • ppr()and supsmu() get an optional trace argument, and ppr(.., sm.method = ..spline) is no longer limited to sample size n <= 2500.
  • The POSIXctmethod for print() gets optional tz and usetz arguments, t
  • New function check_packages_in_dir_details()in package tools for analyzing package-check log files to obtain check details.
  • Package tools now exports function CRAN_package_db()for obtaining information about current packages in the CRAN package repository, and several functions for obtaining the check status of these packages.
  • Den (default) Stangle driver Rtangleallows annotate to be a function and gets a new evalFALSE option.
  • The default method for quantile(x, prob)should now be monotone in prob, even in border cases, see PR#16672.
  • report()now tries to extract an email address from a BugReports field, och om det finns ingen, from a Contacts field.
  • The format()and print() methods for size() results get new options standard and digits; i synnerhet, standard = “IEC” and standard = “OCH” allow more standard (men mindre vanligt) förkortningar än standard som, t.ex.. för kilobyte.
  • Om en referens klass har en giltighets metod, validObjectwill be called automatically from the default initialization method for reference classes.
  • tapply()gets new option default = NA allowing to change the previously hardcoded value.
  • DCF()nu konsekvent tolkar någon ’blanktecken’ som ska skalas för att innehålla flera rader.
  • The maximum number of DLLs that can be loaded into R e.g. vialadda() can now be increased by setting the environment variable R_MAX_NUM_DLLS before starting R.
  • Att tilldela till ett element i en vektor bortom den aktuella längden nu över-allokerar av en liten bråkdel. Den nya vektorn markeras internt som utvidgningsbara, and the true length of the new vector is stored in the truelength This makes building up a vector result by assigning to the next element beyond the current length more efficient, though pre-allocating is still preferred. The implementation is subject to change and not intended to be used in packages at this time.
  • Loading the parallel package namespace no longer sets or changes the .Random.seed, even if R_PARALLEL_PORT is unset.

NB: This can break reproducibility of output, and did for a CRAN package.

  • Methodswget”och “curlfor file() now give an R error rather than a non-zero return value when the external command has a non-zero status.
  • Encoding nameutf8is mapped toUTF-8”. Many implementations of iconv acceptutf8”, but not GNU libiconv (including the late 2016 version 1.15).
  • sessionInfo()shows the full paths to the library or executable files providing the BLAS/LAPACK implementations currently in use (not available on Windows).
  • The binning algorithm used by bandwidth selectors ucv(), bw.bcv()and bw.SJ() switches to a version linear in the input size n for n > nb/2. (The calculations are the same, but for larger n/nb it is worth doing the binning in advance.)
  • There is a new option PCRE_studywhich controls when grep(perl = TRUE) and friends ‘study’ the compiled pattern. Previously this was done for 11 or more input strings: it now defaults to 10 or more (but most examples need many more for the difference from studying to be noticeable).
  • grep(perl = TRUE)and friends can now make use of PCRE’s Just-In-Time mechanism, for PCRE >=20 on platforms where JIT is supported. It is used by default whenever the pattern is studied (see the previous item). (Based on a patch from Mikko Korpela.)

This is controlled by a new option PCRE_use_JIT.

Note that in general this makes little difference to the speed, and may take a little longer: its benefits are most evident on strings of thousands of characters. As a side effect it reduces the chances of C stack overflow in the PCRE library on very long strings (millions of characters, but see next item).

Warning: segfaults were seen using PCRE with JIT enabled on 64-bit Sparc builds.

  • There is a new option PCRE_limit_recursionfor grep(perl = TRUE) and friends to set a recursion limit taking into account R‘s estimate of the remaining C stack space (eller 10000 if that is not available). This reduces the chance of C stack overflow, but because it is conservative may report a non-match (with a warning) in examples that matched before. By default it is enabled if any input string has 1000 or more bytes. (PR#16757)
  • getGraphicsEvent()now works on X11(type =cairo”) Tack vare Frederick Eaton (för att återuppliva en tidigare patch).
  • There is a new argument onIdlefor getGraphicsEvent(), vilket möjliggör en R-funktion som ska köras när det inte finns några väntande grafik evenemangs. Detta är för närvarande endast stöds på X11-enheter. Tack vare Frederick Eaton.
  • The deriv()and similar functions now can compute derivatives of log1p(), sinpi() and similar one-argument functions,
  • median()gains a formalargument, så metoder med extra argument kan ges.
  • strwrap()reduces indent if it is more than half width rather than giving an error.
  • When the condition codein if(.) or while(.) is not of length one, an error instead of a warning may be triggered by setting an environment variable, see the help page.
  • Formatting and printing of bibliography entries (bibentry) is more flexible and better documented. Apart from setting options(citation.bibtex.max = 99)you can also use print(<citation>, bibtex = TRUE) (or format(..)) att få BibTeX poster i fråga om mer än en post. This also affects citation(). Contributions to enable style = “html + bibtex” are welcome.

Tala Your Mind