write_ind {genio} | R Documentation |
Write Eigenstrat *.ind files
Description
This function writes a tibble with the right columns into a standard Eigenstrat *.ind file.
It uses readr::write_tsv()
to do it efficiently.
Usage
write_ind(file, tib, verbose = TRUE)
Arguments
file |
Output file (whatever is accepted by |
tib |
The tibble or data.frame to write.
It must contain these columns: |
verbose |
If |
Value
The output tib
invisibly (what readr::write_tsv()
returns).
See Also
Eigenstrat IND format reference: https://github.com/DReichLab/EIG/tree/master/CONVERTF
Examples
# to write an existing table `ind` into file "data.ind", run like this:
# write_ind("data", ind)
# this also works
# write_ind("data.ind", ind)
# The following example is more detailed but also more awkward
# because (only for these examples) the package must create the file in a *temporary* location
# create a dummy tibble with the right columns
library(tibble)
tib <- tibble(
id = 1:3,
sex = 1,
label = 1
)
# a dummy file
file_out <- tempfile('delete-me-example', fileext = '.ind') # will also work without extension
# write the table out in *.ind format (no header, columns in right order)
write_ind(file_out, tib)
# delete output when done
file.remove(file_out)