我正在尝试从 GitHub 安装包 personograph,该包已在 CRAN 上正式提供。 这是我输入的内容
install.packages("devtools")
devtools::install_github("joelkuiper/personograph")
我收到此错误
Error in install.packages : Updating loaded packages
Downloading GitHub repo joelkuiper/personograph@HEAD
── R CMD build ─────────────────────────────────────────────────────────────────────────────
✔ checking for file 'C:\Users\-\AppData\Local\Temp\RtmpU9Efwx\remotes3644595027e1\joelkuiper-personograph-b3249af/DESCRIPTION' (463ms)
─ preparing 'personograph': (353ms)
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
Omitted 'LazyData' from DESCRIPTION
─ building 'personograph_0.1.3.tar.gz'
Installing package into ‘C:/Users/-/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
* installing *source* package 'personograph' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in x > 0 && rounded == 0 : 'length = 5' in coercion to 'logical(1)'
Error: unable to load R code in package 'personograph'
Execution halted
ERROR: lazy loading failed for package 'personograph'
* removing 'C:/Users/-/AppData/Local/R/win-library/4.3/personograph'
Warning: installation of package ‘C:/Users/-/AppData/Local/Temp/RtmpU9Efwx/file3644413f3ae3/personograph_0.1.3.tar.gz’ had non-zero exit status
想知道我做错了什么;也许我的 R/RStudio 版本太新或者我安装不正确。我知道 2 年前,personograph 已从 CRAN 下架,我认为通过 GitHub 可能会起作用。
我首先尝试从 CRAN 安装,然后从 GitHub 存储库安装,然后更新了我的 R 和 RStudio 版本
我对该包或其维护者一无所知,但查看源代码:该包有“错误的代码”。具体来说,在
R/personograph.R#228
中,我们看到
round.with.warn <- function(x, f=round.standard, name=NULL) {
rounded <- f(x)
if(x > 0 && rounded == 0) {
warning(paste("truncating", ifelse(is.null(name), "a", name), "non-zero value of", x, "to 0"))
}
rounded
}
在相邻函数(例如,
round.standard
)中,允许x
的长度> 1,因此人们也可以推断出这一点。然而,if(x > 0 ...)
就是不好。
NEWS
),进行了更改以将其转换为错误(而不是警告,直到 4.1 为止)。
* Calling if() or while() with a condition of length greater than one gives
an error rather than a warning. Consequently, environment variable
_R_CHECK_LENGTH_1_CONDITION_ no longer has any effect.
在 R-4.3.0 中,这已扩展为包括
&&
和 ||
的 LHS 上的任何内容:
* Calling && or || with LHS or (if evaluated) RHS of length greater than one
is now always an error, with a report of the form
'length = 4' in coercion to 'logical(1)'
Environment variable _R_CHECK_LENGTH_1_LOGIC2_ no longer has any effect.
再次查看
personograph.R
文件,我们看到round.with.warn
在personograph()
中被调用了一次。由于该函数具有包含 @examples
代码的文档,该代码not 包含在 \dontrun{..}
(personograph.R#L285-L293
) 中
#' @examples
#' data <- list(first=0.9, second=0.1)
#' personograph(data)
#' # With colors
#' personograph(data, colors=list(first="red", second="blue"))
#' # With different icon.style
#' personograph(data, icon.style=4) # numeric from 1-11
#' # Plot a thousand in a 20x50 grid
#' personograph(data, n.icons=1000, dimensions=c(20,50), plot.width=0.75)
此示例代码在检查软件包安装时运行。因为里面的
round.with.warn
坏了,所以包安装失败。
鉴于该软件包的最后一次提交(b3249af)是在 2015 年 11 月 6 日进行的,并且此后的任何问题都没有收到作者的任何评论,我认为该软件包不太可能由任何人维护.
我认为此时你的三个选择:
personograph
包。git clone https://github.com/joelkuiper/personograph.git
到您计算机的本地目录,修复代码,并且仅在本地安装它,而不推送回任何存储库。