Hi!

I am studying differences between R and S-PLUS smooth() functions. I know
from the help that they worked differently, so I ask:
 - exist a package that permit to have the same results?
 - alternatively, someone know how can I obtain the same results in R, using
a self made script?

I know that S-PLUS use the 4(3RSR)2H running median smoothing and I try to
implement it with the code below. I obtain some result equal to the S-PLUS
one, so I think the main problem is understand how NA value from moving
median are treated.

The R result is:
 [1]     NA     NA 4.6250 4.9375 4.7500 4.0000 3.2500 3.0000
 [9] 2.8750 2.5000 2.1250

the S-PLUS one is:
 [1]   *   *   *   4.6250 4.9375 4.7500 4.0000 3.2500 3.0000    *    *

where * stand for a number different from the R one that I don't remember.
 Unfortunately I cannot give more details about the S-PLUS function now,
because I am working on a machine without this software. If someone can help
me, tomorrow (CET time), I will provide more details.

Thanks in advance.

Nicola


### EXAMPLE
# Comments indicates which step of the 4(3RSR)2H algorithm I try to
replicate.

# Data
x1 <- c(4, 1, 3, 6, 6, 4, 1, 6, 2, 4, 2)

# 4
out = NULL
for (i in 1:11) {out[i] = median(x1[i:(i+3)])}
out[is.na(out)] = x1[is.na(out)]
out

# (3RSR)
x2 = smooth(out, "3RSR", twiceit = F)
x2

# 2
out2 = NULL
for (i in 1: 11) {out2[i] = median(x2[i:(i+1)])}
out2[is.na(out2)] = x2[is.na(out2)]
out2

# H
filter(out2, filter = c(1/4, 1/2, 1/4), sides = 2)

	[[alternative HTML version deleted]]

