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.
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
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.
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’
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.
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:
.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"