diff --git a/R/onLoad.R b/R/onLoad.R index d918db152..026327cd9 100644 --- a/R/onLoad.R +++ b/R/onLoad.R @@ -70,10 +70,11 @@ # no delayed registration support for NAMESPACE; perform it manually if (isNamespaceLoaded("knitr")) { registerS3method("knit_print", "data.table", knit_print.data.table, envir = asNamespace("knitr")) + } else { + setHook(packageEvent("knitr", "onLoad"), function(...) { + registerS3method("knit_print", "data.table", knit_print.data.table, envir = asNamespace("knitr")) + }) } - setHook(packageEvent("knitr", "onLoad"), function(...) { - registerS3method("knit_print", "data.table", knit_print.data.table, envir = asNamespace("knitr")) - }) } # Set options for the speed boost in v1.8.0 by avoiding 'default' arg of getOption(,default=)