I have two dataframes
> head(a[1:4,1:4])
Tumor_Sample_Barcode Chromosome Position End_Position
1: A1 chr4 90169866 90169866
2: A1 chr11 60235747 60235747
3: A1 chr1 983023 983023
4: A1 chr1 11346060 11346060
>
> head(c)
Chromosome Position VAF
1: chrM 6691 0.610284
2: chrM 14503 0.693325
3: chr1 31412236 0.645161
4: chr1 55693305 0.602941
5: chr1 69963412 0.709302
6: chr1 72608266 0.720000
>
> str(c)
Classes ‘data.table’ and 'data.frame': 44175 obs. of 3 variables:
$ Chromosome: chr "chrM" "chrM" "chr1" "chr1" ...
$ Position : num 6691 14503 31412236 55693305 69963412 ...
$ VAF : num 0.61 0.693 0.645 0.603 0.709 ...
- attr(*, ".internal.selfref")=<externalptr>
I want to merge them like this but complaining about not being integer
> a=a[c, on = c("Chromosome","Position"), VAF := i.VAF]
Error in bmerge(i, x, leftcols, rightcols, roll, rollends, nomatch, mult, :
Incompatible join types: x.Position (character) and i.Position (integer)
I have tried something like these but not working
> c=c[!is.na(as.numeric(as.character(c$Position))), ]
>
> c=c[!is.na(as.numeric(as.character(c$VAF))), ]
>
> c$VAF <- as.numeric(as.character(c$VAF))
c$Position <- as.numeric(as.character(c$Position))
which not working
str(head(a[1:4,1:4]))
$\endgroup$c[, position := as.integer(position)]
$\endgroup$