Hi!
I have a problem with a Counter function. I want to set a column in my database with a counter that when it arrive to 500, it restart to 10. This is my actual code:
I use this type of counter because I want to run a function on the first 10 rows, and a second function on a range a second function repeated on a scalar range of 500 rows
(Can you explain to me what is the meaning of %>% and where I can use it?)
I have a database with about 1.300 rows and what I want is:
1:10 rows -> function a
11:500 rows -> function b
501:1000 rows -> restart function b
and so on, until the end of the lines
but this implies that function b first gets 490 rows to process and then gets 500 rows to process.
which is different than my latest solution... is that correct or not ?
its just an example that I can categorise consecutive rows in the desired way.
You haven't attemped to give an example of a function you have in mind, or how you intend to call it ...
I dont know what you are telling me with 289 and 300 and whatever, ...
In the latest version of my code, the final function was:
TotalControl <- function(database){
for(i in 1:nrow(database)){
if (i < 11) {
FirstControll(database)
}else{
if (i > 10 & i < 501){
SecondControll(database)
}
}
}
}
}
TotalControl(db_class)
Now I want that when my algorithm arrives at line 501, it reads it as line 11 and repeats the instructions of the SecondControll function
I urge you to think carefully about expressing your explanations.
now your code and explanations all point to treating the first 10 records one way, and all the rest of the records another way. this means again that we have wasted time on complicated solutions for simple outcomes
> Error: Problem with `mutate()` input `result`.
> x new columns would leave holes after existing columns
> ℹ Input `result` is `ifelse(rn <= 10, FirstControll(db_class2), SecondControll(db_class2))`.
> Run `rlang::last_error()` to see where the error occurred.
Ok, I make a replex of my code (sorry I'm a beginner and I didn't know how to make it). So the functions work, but I can't get them to start for the various ranges