[R] Loop to check for large dataset

ruipbarradas at sapo.pt ruipbarradas at sapo.pt
Sat Oct 8 14:32:25 CEST 2016


Hello,

I'm not at all sure if the following is what you need but instead of

for (i in length(FD$WEEK))

try

for (i in 1:length(FD$WEEK))

or even better

for (i in seq_len(FD$WEEK))

And use Control[i, 1], not Control[, 1]

Hope thi helps,

Rui Barradas





Citando Christoph Puschmann <c.puschmann at student.unsw.edu.au>:

> 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
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list