Displaying 2 results from an estimated 2 matches for "nbday".
Did you mean:
bday
2010 Feb 12
3
Code working but too slow, any idea for how to speed it up ?(no loop in it)
...th matrix with 103 columns and 164 rows.
sequence <- matrix(seq(1 : ncol(mat1)))
returns <- apply(sequence, 1, function, mat1= mat1, mat2 = mat2, day = 1)
function<- function(mat1, mat2, colNb, day){
mat1<- matrix(mat1[, colNb] )
mat2<- matrix(mat2[, colNb])
nbDays <- length(mat1)
returns <- abs(mat1[1:(nbDays - day)]) * ((as.ts(lag(mat2,
day))/as.ts(mat2))^mat1[1:(nbDays - day)] - 1)
return(returns)
}
I am wondering if the fact of using lag and ts is not slowering down the
code, any idea?
-----
Anna Lippel
--
View this message in co...
2013 Jan 12
1
How to extract value for specific rows in an array?
...olumn array
using the loop below. I tried creating a new empty array for recording the
date for each daily max depth value, but it doesn't seem to be working...
Any ideas or suggestions?
DF <- data.frame(date,day,depth)
samplesperday <- 2*60*24 # number of datapoints per day (2880 here)
nbdays<- nrow(DF)/samplesperday # number of days in the dataset (5 here)
MaxDepth <- array(NaN,c(nbdays,1)) # create empty array where max depth
values will be stored
Date <- array(NaN,c(nbdays,1)) # create empty array where date for max
depth values will be stored
for (i in 1:nbdays){
day...