R/fixnonasc.R

Defines functions fixNonASCII

fixNonASCII = function(df) {
 hasNonASCII = function(x) {
   asc = iconv(x, "latin1", "ASCII")
   any(asc != x | is.na(asc))
 }
 havebad = sapply(df, function(x) hasNonASCII(x))
 if (!(any(havebad))) return(df)
 message("NOTE: input data had non-ASCII characters replaced by '*'.")
 badinds = which(havebad)
 for (i in 1:length(badinds))
   df[,badinds[i]] = iconv(df[,badinds[i]], to="ASCII", sub="*")
 df
}

Try the gwascat package in your browser

Any scripts or data that you put into this service are public.

gwascat documentation built on Nov. 8, 2020, 11:08 p.m.