# [R] Loop to check for large dataset

Sat Oct 8 14:32:34 CEST 2016

```It would help to have a minimal, reproducible example.
Unless revealing the structure of your FD object, it is difficult to
understand how a column having 61327 values would be "consistent over an 1
to 157 interval": is this interval cyclic until it reaches 61327 values?

>From your example using FD\$WEEK, you are using a column called WEEK within
a dataframe names FD, and you only loop over the first 157 values of that
column. So where is the "column having 61327 values"?

For these types of problems you don't even need a loop, R is a vectorised
language (please note that you have a double loop but never use the "i"
one).

Very unclear, so please try to create a MRE, as the posting guide advices.

On Fri, Oct 7, 2016 at 11:22 PM, Christoph Puschmann <
c.puschmann at student.unsw.edu.au> wrote:

> Hey all,
>
> I would like to know if anyone, can put in the right direction of the
> following problem:
>
> I am currently want to use it to check if a column with a length of 61327
> is consistent over an 1 to 157 interval until the end of the column. In the
> case the interval is interrupted I want to know which values are missing
> and where the missing values are located. I started of with the following
> code to assign 1s, if we have a number ≤ 157 and 0 if not.
>
>
>
> I tried to do a double loop:
>
>
>
>     n=61327
>     Control = matrix(
>     0,
>     nrow = n,
>     ncol = 1)
>
>
>
>     for (i in length(FD\$WEEK)) {
>     for (j in 1:157) {
>     if(FD\$WEEK[j] <=  157) {
>       Control[,1] = 1
>     } else {
>       Control[,1] = 0
>       }
>     }
>     }
>
>
>
> I believe that this code is not correct, but I am unable to wrap my head
> around how I can check that the interval always will be followed.
>
> All the best,
>
> Christoph
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--