Displaying 2 results from an estimated 2 matches for "mymin".
Did you mean:
ymin
2005 May 16
1
Omitting NAs in aggregate.ts()
I have a time series vector (not necessarily ts class) that has NAs in
it.
How can I omit the NAs when using aggregate.ts() to compute a function
on each window? If there is at least one non-NA value in each window,
I'd like to proceed with evaluating the function; otherwise, I would
like NA returned. I'm not wedded to aggregate.ts and don't need ts
class if there is another fast,
2012 Apr 06
3
filling the matrix row by row in the order from lower to larger elements
...Thank you very much for the tips!
Dimitri
input<-as.matrix(data.frame(a=c(5,1,3,7),b=c(2,6,4,8)))
(input)
desired.result<-as.matrix(data.frame(a=c(100,0,100,0),b=c(0,100,0,100)))
(desired.result)
result<-as.matrix(data.frame(a=c(0,0,0,0),b=c(0,0,0,0)))
for(i in 1:nrow(input)){ # i<-1
mymin<-i
mycoords<-which(input==mymin,arr.ind=TRUE)
result[i,mycoords[2]]<-100
input[mycoords]<-max(input)
}
(result)
--
Dimitri Liakhovitski