Your code as is cannot be run because it is incomplete. You should make a reprex that runs even if it does produce errors. You may have to modify and reduce you application code to make an example that we can run.You should also show what result you expected. Here is an example of the general structure you could use:
# reduce your code to just enough
# the problem
#
#all the variables needed to run lookp
a = 1:5
b = 0
# loop, probably a reduced version of what
# is in your application
for(i in a) {
b = b + i
}
# show result
b
#> [1] 15
# expected b to be 30 at end of loop
expected_b = 30
# test that checks to see if b is what you expected
identical(b, expected_b)
#> [1] FALSE
Created on 2018-03-26 by the reprex package (v0.2.0).
Here is some info about reprex's. If you have any problems making reprex's work please come back here and we will help you get things going. Note that reprex's are useful not just for questions but for development too.
A prose description isn't sufficient, you also need to make a simple reprex that:
- Builds the input data you are using.
- The function you are trying to write, even if it doesn't work.
- Usage of the function you are trying to write, even if it doesn't work.
- Builds the output data you want the function to produce.
You can learn more about reprex's here:
Right now the is an issue with the version of reprex that is in CRAN so you should download it directly from github.
Until CRAN catches up with the latest version install reprex with
devtools::install_github("tidyverse/reprex")
if this gives you an error saying that devtools is not available then use
install.packages("devtools")
and try again.
The reason we ask for a reprex is that it is the easiest and quickest way for someone to understand the issue you are running into and answer it.
Nearly everyone here who is answering questions is doing it on their own time and really appreciate anything you can do to minimize that time.