Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从错误的.Rbuildignore文件生成后,包中缺少Collate字段中的文件_R_Build_Package - Fatal编程技术网

从错误的.Rbuildignore文件生成后,包中缺少Collate字段中的文件

从错误的.Rbuildignore文件生成后,包中缺少Collate字段中的文件,r,build,package,R,Build,Package,我的包中的一个函数在生成时拒绝添加到包源中,然后在运行R CMD check时失败 我的包位于github上。文件calculate_latitude_and_longitude.R肯定存在于R目录中: $ ls R calculate_latitude_and_longitude.R clean_coordinates_XBLOCK.R clean_crime_data.R load_crime_data_by_ward.R clean_coordinates.R clean_coord

我的包中的一个函数在生成时拒绝添加到包源中,然后在运行R CMD check时失败

我的包位于github上。文件calculate_latitude_and_longitude.R肯定存在于R目录中:

$ ls R  
calculate_latitude_and_longitude.R clean_coordinates_XBLOCK.R  clean_crime_data.R
load_crime_data_by_ward.R clean_coordinates.R
clean_coordinates_YBLOCK.R dccrimedata-package.R
我可以构建这个包,但是由于某些原因,构建没有包含文件calculate_latitude_和_longitude.R。我可以通过浏览tarball中的R目录来验证它是否跳过了这个文件

安装或运行
R CMD check dccrimedata_0.1.tar.gz
后,我在00install.log文件中发现以下错误:

Error in .install_package_code_files(".", instdir) :
files in 'Collate' field missing from '/Users/erikshilts/workspace/dc_crime_data/dccrimedata.Rcheck/00_pkg_src/dccrimedata/R':
  calculate_latitude_and_longitude.R
ERROR: unable to collate and parse R files for package ‘dccrimedata’
我尝试过重命名函数、创建新文件、注释行、删除roxygen标记等,但这些都无助于将函数放入包中

知道怎么回事吗

该函数的完整代码如下所示:

#' Calculate Latitude and Longitude
#'
#' Calculates latitude and longitude from XBLOCK AND YBLOCK coordinates.
#' The coordinates are given in the NAD 83 projection, Maryland state plane,
#' with units in meters. Documentation for this calculation can be found in the
#' README file.
#'
#' @param crime_data data.frame of crime records
#' @return data.frame with two additional columns, latitude and longitude, with units in the standard GPS format
#' @export
calculate_latitude_and_longitude <- function(crime_data) {
  xy_coords <- crime_data[, c('XBLOCK', 'YBLOCK')]

  coordinates(xy_coords) <- c('XBLOCK', 'YBLOCK')

  # NAD83, maryland state plane, units in meters
  proj4string(xy_coords) <- CRS("+init=esri:102285")
  # Transform to latitude and longitude for GPS
  xy_coords <- spTransform(xy_coords, CRS("+init=epsg:4326"))

  xy_coords <- as.data.frame(xy_coords)
  names(xy_coords) <- c('longitude', 'latitude')

  crime_data <- cbind(crime_data, xy_coords)

  crime_data
}

您会注意到,我没有在
.git
中转义句点,这导致它忽略任何包含“Xgit”的文件(X是任何字符),从而导致它忽略我的文件“calculate_latitude_and_lon*git*ude.R”

该.Rbuildignore文件错误地转义了
.git
中的句点。下面是.Rbuildignore文件:

.git
.Rhistory
.Rcheck
\.tar\.gz$
out
<> > <>代码> Git < /代码>使它忽略了“经度”一词所命名的文件,因为单词中间的“git”。

.Rbuildignore文件应如下所示:

\.git
\.Rhistory
\.Rcheck
\.tar\.gz$
out

正则表达式的乐趣

您的描述文件是什么样子的?您可以在这里看到描述文件:您是否运行了
roxygenize
?git存储库中没有“man”目录。是的,bin/目录中有一个脚本可以运行roxygenize。
.git
.Rhistory
.Rcheck
\.tar\.gz$
out
\.git
\.Rhistory
\.Rcheck
\.tar\.gz$
out