无法在R中创建包

时间:2018-05-15 22:32:51

标签: r

我正在尝试在R中创建自定义程序包,但我无法解决此问题。我使用R studio中的界面创建了包。似乎只要保存f

这是我的代码:

#' Imports Multiple files from a given folder
#' @param 
#' @keywords 
#' @export
#' @examples
#' import_folder
import_folder <- function(path,skip){
  hdr <- NA
  files <- list.files(path)
  for(i in 1:length(files)){
    if(substr(files[i],nchar(files[i])-3,nchar(files[i]))==".csv"){
      assign(tolower(make.names(files[i])),read.csv(files[i]),envir=globalenv())

    } else if (substr(files[i],nchar(files[i])-3,nchar(files[i]))==".txt"){
      hdr[i] <- read.table(files[i],header = FALSE, skip = if(missing(skip)){1} else {skip}, sep = "*", row.names = NULL, fill = TRUE, nrows = 1)
      assign(tolower(make.names(files[i])), read.fwf(files[i],
                                                     widths=nchar(strsplit(as.character(hdr[[i]]),"\\|")[[1]])+1,
                                                     header=FALSE,
                                                     skip=2,
                                                     row.names = NULL,
                                                     fill=TRUE),envir=globalenv())
      remove(hdr)

    } else if (substr(files[i],nchar(files[i])-3,nchar(files[i]))=="xlsx"){
      assign(tolower(make.names(files[i])),read.xlsx(files[i],sheet=1),envir=globalenv())

    } else
      print(paste("Could not read",make.names(files[i]),sep=" "),envir=globalenv())

  }
}

devtools::document()

然而,当我运行文档行时,我得到了这个:

Updating mghnywl documentation
Loading mghnywl
Updating mghnywl documentation
Loading mghnywl
Updating mghnywl documentation
Loading mghnywl
Updating mghnywl documentation
Loading mghnywl
Updating mghnywl documentation
Loading mghnywl

.....

直到超时才会停止。

我完全迷失了。我做错了什么?

0 个答案:

没有答案