this question has answer here:
i have df
like:
a b c d | va na 2 na 3 | x 1 2 3 4 | x na 5 5 2 | x 4 3 2 1 | x
it needed like:
a b c d | va 1 2 3 4 | x 4 3 2 1 | x
the aim of calculate va
value. have calculate rules (lets name vb
), has low quality. therefore, need calculate va
better values, can (where there no na
in row). need v
vector, va
calculated rows , vb
everywhere else. illustration of need:
va vb -> v na 2 -> 2 1 2 -> 1 na 2 -> 2 1 2 -> 1
so, have 2 questions:
1) how rescale original df
newdf
, each row has no nas respect original index in df
?
2) have tried va[is.na(va)] <- vb
test na
replacement vb
values (low quality model). worked message different length/number of replacements. ok use need or maybe there better?
we can use rowsums
, is.na
subset rows of "df"
df[!rowsums(is.na(df)),] # b c d va #2 1 2 3 4 x #4 4 3 2 1 x
Comments
Post a Comment