Is there a way to use data.table::fwrite to write the values of a column without any separation between them?
For example:
library("data.table")
geno <- data.table(
IID = 1:10,
SNP = lapply(1:10, function(i) sample(0:2, 10, replace = TRUE))
)
fwrite(geno, "Geno.txt", col.names = FALSE, sep = " ", sep2 = c("","",""))
But the sep2 does not allow it and gives me the following error:
Error in fwrite(geno, "Geno.txt", col.names = FALSE, row.names = FALSE, :
is.character(sep2) && length(sep2) == 3L && nchar(sep2[2L]) == .... is not TRUE
I would like to have the following result, without having to collapse all values before writing it to a file.
1 2221210202
2 0020010221
3 1010022212
4 0120121221
5 1212211202
6 2100002010
7 1110011210
8 1212012121
9 2221121021
10 1122220101
Thank you.