View source: R/split_data_prep.r
split_data_prep | R Documentation |
Function to split a data.prep analysis object into multiple smaller objects in preparation for parallelized analysis.
split_data_prep(data.prep.object, splitBy, keepN)
data.prep.object |
Character string. Name of the |
splitBy |
Character string. Name of the column by which to split the |
keepN |
Numeric scalar. The number of test subjects desired in each sub file. |
split_data_prep
splits the data.prep
analysis object into multiple files, each with equal
numbers of test subjects (except for the final file unless the total number of test subjects is a multiple of
splitBy
). A 'test subject' is e.g. ‘INDLABEL’ for hybrid index estimation on each individual, or
‘locus’ for genomic cline estimation on individual loci. The resulting objects are written to the working
directory as csv files and removed from the workspace. These can then be loaded into R and used as the
data.prep.object
in downstream functions. csv files are quite memory-heavy but load quickly.
No output is returned in the workspace.
Richard Ian Bailey richardianbailey@gmail.com
## Not run:
#Make a set of data.prep files, one for each individual.
split_data_prep(
data.prep.object=prepdata$data.prep, #The data analysis table#
splitBy="INDLABEL", #The planned test subject (usually "INDLABEL" for hybrid index estimation, "locus" for genomic cline estimation)#
keepN=1 #The number of test subjects you want in each resulting file#
)
#Make another set of files, one for each set of 10 loci.
split_data_prep(
data.prep.object=prepdata$data.prep, #The data analysis table#
splitBy="locus", #The planned test subject (usually "INDLABEL" for hybrid index estimation, "locus" for genomic cline estimation)#
keepN=10 #The number of test subjects you want in each resulting file
#(the final file will contain fewer if the total is not a multiple of this number)#
)
#The entry for the 'splitBy' option will be included in the filename for each resulting csv file.
#Therefore, to create a list of files for analysis e.g. of the 'locus' files above:
files=list.files(pattern="_locus_")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.