I've used full.joint to combine two tables:
fsts = full_join(fstvarcal, fst, by = "SNP")
And this had the effect of grouping 1st rows for which there were values for the two datasets, followed by rows for which there were values for the 1st dataset only (and NAs for the 2nd), followed by rows for which there were values for the 2nd dataset only (and NAs for the 1st).
I'm now trying to order by natural order.
Looking for the equivalent of sort -V -k1
in bash.
I've been tried:
library(naturalsort)
;
fstordered = fsts[naturalorder(fsts$SNP),]
which works, but it's very slow.
Any faster ways of doing this? Or of doing merging the two datasets without loosing the natural order?
I have:
SNP fst
scaffold_0 0.186473
scaffold_9 0.186475
scaffold_10 0.186472
scaffold_11 0.186470
scaffold_99 0.186420
scaffold_100 0.186440
and
SNP fstvarcal
scaffold_0 0.186472
scaffold_8 0.186475
scaffold_20 0.186477
scaffold_21 0.186440
scaffold_999 0.186450
scaffold_1000 0.186420
and wan to combine into
SNP fstvarcal fst
scaffold_0 0.186472 0.186473
scaffold_8 0.186475 NA
scaffold_9 NA 0.186475
scaffold_10 NA 0.186472
scaffold_11 NA 0.186470
scaffold_20 0.186477 NA
scaffold_21 0.186440 NA
scaffold_99 NA 0.186420
scaffold_100 NA 0.186440
scaffold_999 0.186450 NA
scaffold_1000 0.186420 NA