2020-11-20 23:35

read_stan_csv with readr


Use Hadley's read_csv to read in CSV files instead of scan.

Intended Effect:

Speed up CSV reading by nearly a factor of 2. In some preliminary tests, it appeared that this step took about 50% of the time involved in running read_stan_csv, so the total change should be 25% faster for the whole function.

The speed improvements would be even larger if the csv files were compressed, as read_csv can read compressed files very quickly.

How to Verify:

The following line should verify that the model output has not changed for a given file (assuming that this branch is installed as rstan_new and the previous branch is installed as rstan).

all.equal(rstan_new::read_stan_csv("csvfile")$samples, rstan::read_stan_csv("csvfile")$samples)

I'm having trouble building rstan on my machine, so I apologize in advance if it doesn't run smoothly on the first submission.

Side Effects:

None intended


Added a brief mention of how to read compressed files

Reviewer Suggestions:

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):

David J. Harris

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: - Code: GPLv3 (http://opensource.org/licenses/GPL-3.0) - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)


  • 点赞
  • 回答
  • 收藏
  • 复制链接分享