[R] to remove an error with log(zero)

Moohwan Kim kmhlmj2 at gmail.com
Fri Dec 18 02:16:46 CET 2009


Dear R family

I have an arbitrary column vector.
1
2
4
0
7
5
0
0
0
9
11
12
When I attempt to take natural logarithm of the series, as you guess
there is an error message. To overcome this problem, my idea is to
replace a zero or zeros in a row with appropriate numbers.
In order to implement it, I need to detect where zeros are.
Then I am going to take the average of two adjacent neighbors. In the
case of zeros in a row, I guess I might apply the above idea
sequentially.

Would you help me out to escape from this jungle?
Thanks in advance.

Best
Moohwan




More information about the R-help mailing list