gpt4 book ai didi

r - 错误 : unable to collate and parse R files for package - upload to CRAN

转载 作者:行者123 更新时间:2023-12-04 15:44:27 28 4
gpt4 key购买 nike

用户在 R( herehere )中安装软件包时遇到相同的错误消息,解决方案似乎是切换站点镜像或等待维护者修复错误。但是,我在将我的包上传到 CRAN 时遇到了问题,并且在 Mac 上创建的包没有通过 Windows 和 R 的开发人员版本的检查。

有问题的上传到CRAN是第六版的包,第一次出现这个错误。

* installing *source* package 'packagename' ...
** using staged installation
** R
Error in parse(outFile) :
d:/temp/RtmpGW8fFv/R.INSTALL129d81ef3788f/packagename/R/functionname.R:1:1: unexpected '<'
1: <
^
ERROR: unable to collate and parse R files for package 'packagename'
* removing 'd:/RCompile/CRANguest/R-devel/lib/packagename'

我尝试显示不可见的字符,但在不应该出现的任何地方都没有“<”。接下来,我标准化了行尾,手动删除了行首的字符,但没有任何帮助。

有谁知道如何从维护者的角度修复上述错误?

编辑:
描述文件的相关部分:
Depends: R (>= 3.4.0),
License: GPL-3
Encoding: UTF-8
LazyData: true
Imports: limSolve,
quadprog,
stats,
graphics,
grDevices
RoxygenNote: 6.1.1
Suggests: testthat
BuildVignettes: true

该函数使用 base命令和 limSolve::linp .
#' Fuzzy Linear Regression using the Fuzzy Least Absolute Residual Method
#'
#' The function calculates fuzzy regression coeficients using the fuzzy least absolute
#' residual (FLAR) method proposed by Zeng et al. (2017)
#' for non-symmetric triangular fuzzy numbers.
#' @param x matrix with the second to last columns representing independent variable
#' observations. The first column is related to the intercept, so it consists of ones.
#' Missing values not allowed.
#' @param y matrix of dependent variable observations. The first column contains the
#' central tendency, the second column the left spread and the third column the right
#' spread of non-symmetric triangular fuzzy numbers. Missing values not allowed.
#' @details The FLAR method expects real value input for the explanatory variables, and
#' non-symmetric triangular fuzzy numbers for the response variable. The prediction
#' returns non-symmetric triangular fuzzy numbers.
#' @note Preferred use is through the \code{\link{fuzzylm}} wrapper function with argument
#' \code{method = "flar"}.
#' @inherit fuzzylm return
#' @inherit plrls seealso
#' @references Zeng, W., Feng, Q. and Li, J. (2017) Fuzzy least absolute linear regression.
#' \emph{Applied Soft Computing} 52: 1009-1019.
#' @keywords fuzzy
#' @export
#' @examples
#' data(fuzzydat)
#' fuzzylm(y ~ x, fuzzydat$dia, "flar", , , "yl", "yl")

flar <- function(x, y){
vars <- colnames(x)
n <- nrow(x)
p <- ncol(x)
X <- x

I <- diag(n)
Ir <- diag(p)
Z <- matrix(0, ncol = n, nrow = n)
ZX <- matrix(0, nrow = n, ncol = p)
ZXr <- matrix(0, nrow = p, ncol = p)
Zr <- matrix(0, nrow = p, ncol = n)

f <- c(rep(1, 6*n), rep(0, 3*p))

Req <- cbind(I, -I, Z, Z, Z, Z, X, ZX, ZX)
Req <- rbind(Req, cbind(Z, Z, I, -I, Z, Z, ZX, X, ZX))
Req <- rbind(Req, cbind(Z, Z, Z, Z, I, -I, ZX, ZX, X))

leq <- matrix(c(y))

R <- cbind(-I, Z, Z, Z, Z, Z, ZX, ZX, ZX)
R <- rbind(R, cbind(Z, -I, Z, Z, Z, Z, ZX, ZX, ZX))
R <- rbind(R, cbind(Z, Z, -I, Z, Z, Z, ZX, ZX, ZX))
R <- rbind(R, cbind(Z, Z, Z, -I, Z, Z, ZX, ZX, ZX))
R <- rbind(R, cbind(Z, Z, Z, Z, -I, Z, ZX, ZX, ZX))
R <- rbind(R, cbind(Z, Z, Z, Z, Z, -I, ZX, ZX, ZX))
R <- rbind(R, cbind(Zr, Zr, Zr, Zr, Zr, Zr, ZXr, -Ir, ZXr))
R <- rbind(R, cbind(Zr, Zr, Zr, Zr, Zr, Zr, ZXr, ZXr, -Ir))
R <- rbind(R, cbind(Z, Z, Z, Z, Z, Z, ZX, -X, ZX))
R <- rbind(R, cbind(Z, Z, Z, Z, Z, Z, ZX, ZX, -X))

l <- matrix(rep(0, 8*n + 2*p))

sorig <- limSolve::linp(E = Req, F = leq, G = -R, H = -l, Cost = f, ispos = FALSE)
s <- sorig$X

coefs <- matrix(c(s[(6*n+1):(6*n+p)],
s[(6*n+p+1):(6*n+2*p)],
s[(6*n+2*p+1):(6*n+3*p)]), ncol = 3,
dimnames = list(vars, c("center", "left.spread", "right.spread")))
lims <- t(apply(x, 2, range))
rownames(lims) <- vars
colnames(lims) <- c("min", "max")
fuzzy <- list(call = NULL, x = x, y = y, lims = lims,
method = "fls", fuzzynum = "non-symmetric triangular", coef = coefs)
class(fuzzy) <- "fuzzylm"
fuzzy
}

最佳答案

看来我找到了问题的原因和解决方案。具有问题功能的文件是在 Windows (RStudio) 上创建并在 Mac (BBEdit) 上编辑的。 Mac 尝试在编辑期间保留 Windows 行结尾,并且在将文件返回到 Windows 时,编码更改为 UTF8 的一种罕见变体。 Windows 上的 R 编译器无法处理外来编码。

解决方案似乎是始终将所有行结尾强制为 LF跨平台并确保文件编码在不同平台上保持稳定。

关于r - 错误 : unable to collate and parse R files for package - upload to CRAN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56471638/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com