# to write an existing table `phen` into file "data.phen", run like this:
# write_phen("data", phen)
# this also works
# write_phen("data.phen", phen)
# 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(
fam = 1:3,
id = 1:3,
pheno = 1
)
# a dummy file
file_out <- tempfile('delete-me-example', fileext = '.phen') # will also work without extension
# write the table out in *.phen format (no header, columns in right order)
write_phen(file_out, tib)
# delete output when done
file.remove(file_out)
Run the code above in your browser using DataLab