-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1707 from restonslacker/bug/onAttach_Packaged_check
Closes #1706, library(data.table) fails if "Packaged" field is not pr…
- Loading branch information
Showing
2 changed files
with
21 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
.onAttach <- function(libname, pkgname) { | ||
# Runs when attached to search() path such as by library() or require() | ||
if (interactive()) { | ||
v = packageVersion("data.table") | ||
d = read.dcf(system.file("DESCRIPTION", package="data.table"))[,"Packaged"] | ||
dev = as.integer(v[1,3])%%2 == 1 # version number odd | ||
packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d)) | ||
if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********") | ||
packageStartupMessage('For help type ?data.table or https://github.com/Rdatatable/data.table/wiki') | ||
packageStartupMessage('The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way') | ||
# Runs when attached to search() path such as by library() or require() | ||
if (interactive()) { | ||
v = packageVersion("data.table") | ||
d = read.dcf(system.file("DESCRIPTION", package="data.table"), fields = c("Packaged", "Built")) | ||
if(is.na(d[1])){ | ||
if(is.na(d[2])){ | ||
return() #neither field exists | ||
} else{ | ||
d = unlist(strsplit(d[2], split="; "))[3] | ||
} | ||
} else { | ||
d = d[1] | ||
} | ||
|
||
dev = as.integer(v[1,3])%%2 == 1 # version number odd | ||
packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d)) | ||
if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********") | ||
packageStartupMessage('For help type ?data.table or https://github.com/Rdatatable/data.table/wiki') | ||
packageStartupMessage('The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way') | ||
} | ||
} | ||
|