I have an lm object called mro
A summary gives> summary(mro)
Call:
lm(formula = REGRESSIONSTRING, data = wData)
Residuals:
Min 1Q Median 3Q Max
-8.18077 -1.06867 -0.09387 1.03153 11.20201
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.2096 1.0345 6.969 5.37e-11 ***
log(H2403_P1) -0.3113 0.1305 -2.386 0.0180 *
I(LEVDSCRT/100) 3.4425 0.7818 4.403 1.79e-05 ***
REG_UTIL_FLAG_P1 NA NA NA NA
REALESTATE_ROI 0.2413 0.6211 0.389 0.6980
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
'.' 0.1 ' ' 1
Residual standard error: 2.116 on 186 degrees of freedom
Multiple R-squared: 0.1455, Adjusted R-squared: 0.1317
F-statistic: 10.56 on 3 and 186 DF, p-value: 1.917e-06
Now, I know my REG_UTIL_FLAG_P1 var is NA because it is missing/constant
in the data frame.
What I am trying to do is this
tring(summary(mro)$coef[,3])
[1] "6.96900610837729, -2.38577388980627, 4.403441093625,
0.388556365853674">
I'd really like the NA to not be omitted, but cast to 0 (I am going to
load this into a DB)
So I'd like to see
[1] "6.96900610837729, -2.38577388980627, 4.403441093625, 0,
0.388556365853674"
I was able to do that with the coefficients via
mro$coef[is.na(mro$coef)]<-0
mro$coef
I can do this in a brute force way by by getting a vector of aliased
columns and iterating thru it -- but was hoping for a more elegant
solution.
Thx!
===============================================================================
Please access the attached hyperlink for an important electronic communications
disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html