在逐场从文件包中缺少不正确的.Rbuildignore文件后,建 [英] Files in Collate field missing from package after build from incorrect .Rbuildignore file
问题描述
其中的一个功能,我的包在建造时要添加到包源,然后失败运行v CMD检查时。
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.
我的包位于github上这里。该文件,calculate_latitude_and_longitude.R,肯定在R目录存在:
My package is located on github here. The file, calculate_latitude_and_longitude.R, certainly exists in the R directory:
$ 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_and_longitude.R。我能够确认它由焦油球浏览第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.
一旦安装或运行研究CMD检查dccrimedata_0.1.tar.gz
我得到了00install.log文件中出现以下错误:
Upon installing or running R CMD check dccrimedata_0.1.tar.gz
I get the following error in the 00install.log file:
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标签等,但没有它有助于获得该功能进入包。
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.
任何想法是怎么回事?
满code的作用是在这里:
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'
的更新:的
我隔离在名称以经度的转变对任何文件(纬度正常工作)。我在这个回购.Rbuildignore文件看起来是这样的:
I isolated the change to any file with "longitude" in the name ("latitude" works fine). My .Rbuildignore file in this repo looks like this:
.git
.Rhistory
.Rcheck
\.tar\.gz$
out
您会注意到,我不逃避的.git
的操作时间,从而导致它忽略它以Xgit的任何文件(X为任意字符),因此导致它忽略我的文件calculate_latitude_and_lon *的混帐的* ude.R
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"
推荐答案
该.Rbuildignore文件不正确地转义的.git
的操作时间。这里的.Rbuildignore文件:
The .Rbuildignore file incorrectly escapes the period in .git
. Here's the .Rbuildignore file:
.git
.Rhistory
.Rcheck
\.tar\.gz$
out
不正确的的.git
逃脱周期导致其忽略的词,因为这个词中间的混帐的经度命名的文件。
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.
该.Rbuildignore文件应该是这样的:
The .Rbuildignore file should look like:
\.git
\.Rhistory
\.Rcheck
\.tar\.gz$
out
玩转普通防爆pressions!
Fun with Regular Expressions!
这篇关于在逐场从文件包中缺少不正确的.Rbuildignore文件后,建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!