我有一个名为startdates.csv
的CSV文件,我希望将其作为名为tabulations
的R包的一部分提供给同事。各个步骤在开发期间工作,但是在安装和加载包时,会连接data.frame列。以下是详细信息:
根据Hadley Wickham's excellent book和this very helpful summary,我将startdates.csv
放入data-raw/
,并运行以下脚本将其另存为data/startdates.rda
:
startdates <- read.csv("data-raw/startdates.csv")
devtools::use_data(startdates, overwrite=T)
按预期工作:
> source("data-raw/get_tabs.r")
Saving startdates as startdates.rda to /home/matthewroberts7/ieTabs/tabulations/data
> startdates
Dataset Observations Potential_start_date_fields Earliest Latest Missing
1 jeval 6445712 5 30NOV2000 21NOV**** 0.04%
2 jhist 7058169 5 12MAY2001 17SEP**** 2.90%
3 ueval 390783 5 29APR2013 29JUN2016 0.00%
在开发过程中,一切都很好:
> setwd("tabulations")
> devtools::load_all()
Loading tabulations
> tabulations::startdates
Dataset Observations Potential_start_date_fields Earliest Latest Missing
1 jeval 6445712 5 30NOV2000 21NOV**** 0.04%
2 jhist 7058169 5 12MAY2001 17SEP**** 2.90%
3 ueval 390783 5 29APR2013 29JUN2016 0.00%
但是当安装软件包时,就像原始csv已经保存为每行一个字符串一样:
> setwd("..")
> document("tabulations")
Updating tabulations documentation
Loading tabulations
> install("tabulations")
Installing tabulations
...
> reload(inst("tabulations"))
Reloading installed tabulations
> tabulations::startdates
Dataset.Observations.Potential_start_date_fields.Earliest.Latest.Missing
1 jeval,6445712,5,30NOV2000,21NOV****,0.04%
2 jhist,7058169,5,12MAY2001,17SEP****,2.90%
3 ueval,390783,5,29APR2013,29JUN2016,0.00%
有谁可以解释这里发生了什么?非常感谢。
编辑:R v3.4.2,devtools v1.13.4