从错误的.Rbuildignore文件构建后的包中的Collate字段中的文件丢失。

时间:2023-01-17 23:15:26

One of the functions to my package refuses to be added to the package source when built, and then fails when running R CMD check.

我的包中的一个函数在构建时拒绝添加到包源代码中,然后在运行rcmd检查时失败。

My package is located on github here. The file, calculate_latitude_and_longitude.R, certainly exists in the R directory:

我的包裹放在这里的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

I am able to build the package, but the build doesn't include the file calculate_latitude_and_longitude.R for some reason. I am able to verify that it skips this file by browsing the R directory in the tar ball.

我可以构建包,但是构建不包括文件calculate_latitude_and_longitude。R出于某种原因。我可以通过浏览tar ball中的R目录来验证它跳过这个文件。

Upon installing or running R CMD check dccrimedata_0.1.tar.gz I get the following error in the 00install.log file:

在安装或运行rcmd时,检查dccrimedata_0.1.tar。在00install中,我得到了以下错误。日志文件:

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’

I've tried renaming the function, creating a new file, commenting out lines, removing roxygen tags, etc, but none of it helps to get that function into the package.

我试过重命名函数、创建新文件、注释行、删除roxygen标记等等,但是这些都没有帮助将函数放入包中。

Any idea what's going wrong?

知道哪里出了问题吗?

The full code for the function is here:

函数的完整代码在这里:

#' 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
}

My DESCRIPTION file looks like:

我的描述文件如下:

Package: dccrimedata
Title: An R package containing DC crime data.
Description: Crime data from DC from 2006 to mid-2012
Version: 0.1
License: GPL-3
Author: erik.shilts
Maintainer: <erik.shilts@opower.com>
Depends:
    rgdal,sp
Collate:
    'calculate_latitude_and_longitude.R'
    'clean_coordinates_XBLOCK.R'
    'clean_coordinates_YBLOCK.R'
    'clean_coordinates.R'
    'clean_crime_data.R'
    'load_crime_data_by_ward.R'
    'dccrimedata-package.R'

Update:

更新:

I isolated the change to any file with "longitude" in the name ("latitude" works fine). My .Rbuildignore file in this repo looks like this:

我将变更与名称中“经度”的任何文件隔离(“latitude”工作正常)。我的。rbuildignore文件在这个repo中是这样的:

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

You'll notice that I don't escape the period in .git, which caused it to ignore any file with "Xgit" in it (X being any character), hence causing it to ignore my file "calculate_latitude_and_lon*git*ude.R"

您会注意到,我并没有在.git中转义,这导致它忽略了任何带有“Xgit”的文件(X是任何字符),因此导致它忽略了我的文件“calculate_latitude_and_lon*git*ude.R”。

1 个解决方案

#1


8  

The .Rbuildignore file incorrectly escapes the period in .git. Here's the .Rbuildignore file:

. rbuildignore文件不正确地从.git中转义。这是.Rbuildignore文件:

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

The incorrectly escaped period in .git caused it to ignore files named with the word "longitude" because of the "git" in the middle of the word.

在.git中不正确的转义时间导致它忽略了以“经度”这个词命名的文件,因为在单词中间有一个“git”。

The .Rbuildignore file should look like:

.Rbuildignore文件应该如下:

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

Fun with Regular Expressions!

乐趣与正则表达式!

#1


8  

The .Rbuildignore file incorrectly escapes the period in .git. Here's the .Rbuildignore file:

. rbuildignore文件不正确地从.git中转义。这是.Rbuildignore文件:

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

The incorrectly escaped period in .git caused it to ignore files named with the word "longitude" because of the "git" in the middle of the word.

在.git中不正确的转义时间导致它忽略了以“经度”这个词命名的文件,因为在单词中间有一个“git”。

The .Rbuildignore file should look like:

.Rbuildignore文件应该如下:

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

Fun with Regular Expressions!

乐趣与正则表达式!