Exporting data in Roxygen2 so that they are available without requiring data()

﹥>﹥吖頭↗ 提交于 2019-12-21 11:35:11

问题


After reading questions such as this SO question on documenting a data set with Roxygen I have managed to document a dataset (which I will refer to as cells) and it now appears in the list generated by data(package="mypackage") and is loaded if I run the command data(cells). After this, cells will appear when ls() is run.

However, in many packages the data is immediately available without requiring a data() call. Also, the data names do not appear when ls() is run. An example is the baseball data set that comes with plyr. I have looked at the source for plyr and I cannot see how this is done.


回答1:


In the DESCRIPTION file of your package make sure that there is a field called LazyData that is set to TRUE.

From the "Writing R Extensions" guide:

The ‘data’ subdirectory is for data files, either to be made available via lazy-loading or for loading using data(). (The choice is made by the ‘LazyData’ field in the ‘DESCRIPTION’ file: the default is not to do so.)

I think the exact syntax changed with R version 2.14; before that it was LazyLoad not LazyData.



来源:https://stackoverflow.com/questions/11772156/exporting-data-in-roxygen2-so-that-they-are-available-without-requiring-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!