Hello House
I have a time series data set for time(m=1-3hrs) of two variables (uwnd and vwnd). For each iteration in the loop, I want the result to be stored in each column. nrow=95200, ncol =1, time =3.
Below please find my script as its not giving the desired results :
result <- data.frame( ) # initialize vector to store results, length = ncol(mydata)
for (m in 1:3) # for(m in 1:ncol(dname1)).
{
uwnd_10.slice <- dname1[, , m]
vwnd_10.slice <- dname2[, , m]
wsp_slice_10 <- matrix(nrow = nlon, ncol = nlat)
for(i in 1:dim(uwnd_10.slice)[1]) {
for(j in 1:dim(vwnd_10.slice)[2]) {
wsp_slice_10[i,j] <- (((uwnd_10.slice[i])^2) + ((vwnd_10.slice[j])^2))^0.5
}
}
lonlat <- expand.grid(lon, lat)
wsp_slice_10.vec <- as.vector(wsp_slice_10)
wsp_slice_10.df01 <- data.frame(cbind(lonlat, wsp_slice_10.vec))
head(wsp_slice_10.df01)
length(wsp_slice_10.vec)
print(wsp_slice_10.vec)
answ <- (wsp_slice_10.df01[3]) # change to assignment
wsp_answ <- answ
result <- rbind(wsp_answ)
output =result
head(output)
}
length(result)