Al-Murphy / MungeSumstats

Rapid standardisation and quality control of GWAS or QTL summary statistics
https://doi.org/doi:10.18129/B9.bioc.MungeSumstats
75 stars 16 forks source link

non-numeric argument to mathematical function #26

Closed bschilder closed 3 years ago

bschilder commented 3 years ago

Bug at this following step, within check_n_int():

Screenshot 2021-07-11 at 14 37 12

bschilder commented 3 years ago

Issue

check_n_int() assumes N is either numeric or integer, and does not account for characters.

Screenshot 2021-07-13 at 17 49 37

In some instances, N can also be NA: Screenshot 2021-07-13 at 17 55 36

Solution

Check for characters and convert them to integers:

if (convert_n_int) { #if user wants to correct
        msg2 <- paste0(msg," These will be converted to integers.")
        message(msg2)
        if(  is(sumstats_dt$N,"character") ) sumstats_dt[,N:=as.integer(N)]  #### solution HERE
        sumstats_dt[,N:=round(N,0)] 
        return(list("sumstats_dt"=sumstats_dt))
      }