]> git.donarmstrong.com Git - don.git/blob - posts/unnecessary_data_frame_slow.mdwn
Merge branch 'master' of ssh://git.donarmstrong.com/sites/git/don
[don.git] / posts / unnecessary_data_frame_slow.mdwn
1 [[!meta title="Unnecessary Use of data.frame is Slow"]]
2
3 I've been working for a while on a reasonably large Genome-Wide
4 Association Study dataset which has lead me through various
5 interesting parts of handing large datasets in R. This dataset is
6 approximately 320,000 rows by 5000 columns. After getting Rmpi
7 working, and handling the dataset by row so I don't run out of memory,
8 I've managed to get pretty decent performance. However, one small
9 section of the code seemed to be taking forever to run.
10
11 It turns out that assigning data to a data.frame by row is incredibly
12 slow in R. Thus, a section of my code which should have taken
13 microseconds was taking tenths of seconds, and threatening to run all
14 week. Using a matrix instead (which is basically what I want anyway)
15 and converting to a data.frame at the very end makes the code multiple
16 orders of magnitude faster.
17
18 Moral of the story? Don't use data.frame unnecessarily.
19
20 [[!tag tech r]]