문제

I have these two object:

sig (class matrix) and

xts (class xts)

In the first object I want to find the position where this condition is satisfied: "sig != mlag(sig) & sig != 0"

When I have these positions I want to substitute value in the xts object (zero for example) in the same position where the condition in sig was satisfied

I need to understand the correct way to do these. Thank you

올바른 솔루션이 없습니다

다른 팁

Here's one way. I'm not familiar with the mlag function, and you don't say where it comes from, so I'm just going to use diff.xts.

sigSubset <- diff.xts(sig) != 0 & sig != 0
sigSubset[1,] <- FALSE  # remove any NA
x[sigSubset] <- sig[sigSubset]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top