@@ -82,13 +82,15 @@ get.weights <- function(DAT_min, DAT_max) {
8282# '
8383# ' @export calculate.outputrows
8484
85+
86+
8587calculate.outputrows <- function (DAT_mat , stepsize ) {
86- mean_year_index <- which(DAT_mat [," datmax" ]- DAT_mat [," datmin" ] < stepsize )
88+ mean_year_index <- which(DAT_mat [," datmax" ] - DAT_mat [," datmin" ] < stepsize )
8789
8890 if (length(mean_year_index ) == 0 ) {
89- outputrows <- ceiling(sum(((abs(DAT_mat [," datmin " ] - DAT_mat [," datmax " ]))/ stepsize )+ 1 ))
91+ outputrows <- ceiling(sum(((abs(DAT_mat [," datmax " ] - DAT_mat [," datmin " ])) / stepsize ) + 3 ))
9092 } else {
91- outputrows <- ceiling(sum(((abs(DAT_mat [- mean_year_index ," datmin " ] - DAT_mat [- mean_year_index ," datmax " ]))/ stepsize )+ 1 ))
93+ outputrows <- ceiling(sum(((abs(DAT_mat [- mean_year_index ," datmax " ] - DAT_mat [- mean_year_index ," datmin " ]))/ stepsize )+ 3 ))
9294 outputrows <- outputrows + length(mean_year_index )
9395 }
9496 return (outputrows )
@@ -163,7 +165,6 @@ get.step.sequence <- function(datmin = 0, datmax = 100, stepsize = 25) {
163165create.sub.objects <- function (DAT_mat , stepsize ) {
164166
165167 outputrows <- calculate.outputrows(DAT_mat , stepsize )
166-
167168 result <- as.data.frame(matrix (ncol = 6 , nrow = outputrows + 100 ))
168169
169170 diffs <- DAT_mat [," datmax" ]- DAT_mat [," datmin" ]
@@ -176,16 +177,12 @@ create.sub.objects <- function(DAT_mat, stepsize) {
176177
177178 for (i in 1 : nrow(DAT_mat )) {
178179 sequence <- NULL
179-
180180 sequence <- get.step.sequence(DAT_mat [i ," datmin" ], DAT_mat [i ," datmax" ], stepsize )
181-
182- length <- length(sequence )
183181 for (step in sequence ) {
184182 wip <- as.vector(DAT_mat [i ,])
185183 wip [5 ] <- step
186184 wip [4 ] <- wip [4 ] / length(sequence )
187185 first_na <- match(NA , result [,1 ])
188- # ## HIER GIBT ES EIN PROBLEM
189186 result [first_na ,1 ] <- wip [1 ]
190187 result [first_na ,3 ] <- wip [2 ]
191188 result [first_na ,4 ] <- wip [3 ]
0 commit comments