【问题标题】:Minimum required R version for base packages?基本包所需的最低 R 版本?
【发布时间】:2018-02-27 21:10:27
【问题描述】:

有没有办法找出我在我的包中使用的 base、stats 等包功能需要哪个 R 版本?

例如,我使用自己的代码来获取剩余的 SD,然后将其替换为 stats::sigma()。但是,sigma() 需要 R 版本 >= 3.3。反过来,我的包应该依赖于 R >= 3.2,并且包检查和 CRAN 提交都没有警告我的说明文件中 R 依赖项的错误规范...

【问题讨论】:

  • [R 网站] 上有一个更改日志,其中说明了更改。但听起来你想要“给定一个函数,我怎么知道它是什么时候引入的?”
  • 是的,完全正确!可能没有很多函数需要 R > 3.2(甚至 R > 3.0),但是例如startsWith() 是另一个候选者,我不知道它需要一个较晚的 R 版本。

标签: r dependencies package


【解决方案1】:

似乎没有办法以可靠的方式以编程方式执行此操作。一般来说,最简单的方法是处理新闻。以下代码提取 NEWS 中包含“新功能”的所有句子:

library(data.table)
library(stringr)
db <- as.data.table(news())
db <- db[Category == "NEW FEATURES" & grepl("[Nn]ew function[^a]", Text), .(Text, Version)]
db[, Text := str_replace_all(Text, "\n", "")]
db[, Text := str_extract(Text, "[Nn]ew function.*?\\.(?=($| ))"), by = Version]

> db
                                                                                                                                                                                                                 Text Version
 1:                                                                                                                                                                                     new function .valid.factor().   3.4.0
 2:                                                                                      New function check_packages_in_dir_details() in package tools for analyzing package-check log files to obtain check details.   3.4.0
 3:                                                                                             New functions validEnc() and validUTF8() to give access to the validity checks for inputs used by grep() and friends.   3.3.0
 4:                                                                                                                                           New function strrep() for repeating the elements of a character vector.   3.3.0
 5:                                                                                                  New function grouping() returns a permutation that stably rearranges data so that identical values are adjacent.   3.3.0
 6:                                                                                                                                       New function .traceback() returns the stack trace which traceback() prints.   3.3.0
 7:                                    New functions makevars_user() and makevars_site() in package tools to determine the location of the user and site specific Makevars files for customizing package compilation.   3.3.0
 8:                                                                                                New function dir.exists() in package base to test efficiently whether one or more paths exist and are directories.   3.2.0
 9:                                                                                                                         new function debuggingState() has been added, allowing to temporarily turn off debugging.   3.2.0
10:                                                                                                           New function extSoftVersion() to report on the versions of third-party software in use in this session.   3.2.0
11:                                                                                                                                                       New function isNamespaceLoaded() for readability and speed.   3.2.0
12:                                                                                                                                                   New function trimws() for removing leading/trailing whitespace.   3.2.0
13: New function hsearch_db() in package utils for building and retrieving the help search database used by help.search(), along with functions for inspecting the concepts and keywords in the help search database.   3.2.0
14:                                                                                                          New function .getNamespaceInfo(), a no-check version of getNamespaceInfo() mostly for internal speedups.   3.2.0
15:                                                                                                                                          New function toTitleCase() in package tools, tailored to package titles.   3.2.0
16:                                                                                                          New function pcre_config() to report on some of the configuration options of the version of PCRE in use.   3.1.3
17:                                                                                                                               New function icuGetCollate() to report on the ICU collation locale in use (if any).   3.1.2
18:                                             new function promptImport(), to generate a help page for a function that was imported from another package (and presumably re-exported, or help would not be needed).   3.1.1
19:                                                                                         New function anyNA(), a version of any(is.na(.)) which is fast for atomic vectors, based on a proposal by Tim Hesterberg.   3.1.0
20:                                                                                                                               new function find_gs_cmd() in the tools package to locate a GhostScript executable.   3.1.0
21:                                                                                         New functions cospi(x), sinpi(x), and tanpi(x), for more accurate computation of cos(pi*x), etc, both in R and the C API.   3.1.0
22:                                                                                                                                                New function agrepl() which like grepl() returns a logical vector.   3.1.0
23:                                                                                                                                               new function, La_version(), to report the version of LAPACK in use.   3.0.3
24:                                                                                          New functions cite() and citeNatbib() have been added, to allow generation of in-text citations from "bibentry" objects.   3.0.0
25:                                                                                                                     new function rep_len() analogous to rep.int() for when speed is required (and names are not).   3.0.0
26:                                                                    New functions bitwNot(), bitwAnd(), bitwOr() and bitwXor(), using the internal interfaces previously used for classes "octmode" and "hexmode".   3.0.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-05
    • 2015-04-11
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多