r - replace with NA -



r - replace <NA> with NA -

i have info frame containing entries; appears these values not treated na since is.na returns false. convert these values na not find way.

the 2 classes issue character , factor. should loop on dtaframe , convert "na" values true <na>'s 2 classes:

make.true.na <- function(x) if(is.character(x)||is.factor(x)){ is.na(x) <- x=="na"; x} else { x} df[] <- lapply(df, make.true.na)

(untested in absence of info example.) utilize of form: df_name[] effort retain construction of original dataframe otherwise lose class attribute. see ujjwal thinks spelling of na has flanking "<>" characters might seek functions more general:

make.true.na <- function(x) if(is.character(x)||is.factor(x)){ is.na(x) <- x %in% c("na", "<na>"); x} else { x}

r replace na

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -