t;result <- merge(dataset, tmp)
>result$Mean[is.na(result$y) | result$y != 0] <- result$x[is.na(result$y) |
>result$y != 0]
>
>Best regards,
>
>Thierry
>> -----Oorspronkelijk bericht-
>> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
:21
> Aan: r-help@r-project.org
> Onderwerp: [R] how to replace values in x by means in subgroups created in ...
> (not loops)
>
>
> # Dear all,
> # how to replace values in x by means in subgroups created in ...
> # replace only these values where y=0 in continous sequence #
# Dear all,
# how to replace values in x by means in subgroups created in ...
# replace only these values where y=0 in continous sequence
# replace by mean calculated locally for each subgroup created by
# continous sequence of 0,0,0 in parallel y vector, i.e.
# where there is continous sequence
3 matches
Mail list logo