Dear All,
Does anyone know if this is an omission or if there is a reason for doing it in
this way that I am not seeing? These element names seem to be an artefact of
how the information was extracted:
```
getNamespaceName("stats")
#> name
#> "stats"
getNamespaceVersion("stats")
#> version
#> "4.7.0"
```
This is in contrast to `packageVersion()`, which reads it from the
`DESCRIPTION` file but returns an unnamed vector, which leads to unexpected
behaviour:
```
as.package_version(getNamespaceVersion("stats")) == packageVersion("stats")
#> [1] TRUE
identical(as.package_version(getNamespaceVersion("stats")),
packageVersion("stats"))
#> [1] FALSE
identical(as.package_version(unname(getNamespaceVersion("stats"))),
packageVersion("stats"))
#> [1] TRUE
```
The attached patch uses `[[]]` rather than `[]` to extract namespace name and
version, which removes the names. It doesn't seem to break anything, but,
again, there may be another reason.
Best Regards,
Pavel
This email and any files transmitted with it may contain confidential
information. If you believe you have received this email or any of its contents
in error, please notify me immediately by return email and destroy this email.
Do not use, disseminate, forward, print or copy any contents of an email
received in error.
Index: src/library/base/R/namespace.R
===================================================================
--- src/library/base/R/namespace.R (revision 90876)
+++ src/library/base/R/namespace.R (working copy)
@@ -51,7 +51,7 @@
getNamespaceName <- function(ns) {
ns <- asNamespace(ns)
if (isBaseNamespace(ns)) "base"
- else .getNamespaceInfo(ns, "spec")["name"]
+ else .getNamespaceInfo(ns, "spec")[["name"]]
}
getNamespaceVersion <- function(ns) {
@@ -58,7 +58,7 @@
ns <- asNamespace(ns)
if (isBaseNamespace(ns))
c(version = paste(R.version$major, R.version$minor, sep = "."))
- else .getNamespaceInfo(ns, "spec")["version"]
+ else .getNamespaceInfo(ns, "spec")[["version"]]
}
getNamespaceExports <- function(ns) {
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel