1

I have a vector called tKKrs, which is a list of stock tickers. Text strings in this vector also represent names of xts objects. All of the objects are already available in the environment. So is the vector tKKrs

If I want to see the content of an object A (which is the first text string in vector tKKrs), I can either type A or get(tKKrs[1])

However if I run get(tKKrs[i]) inside dopar foreach loop, I get error object A not found.

How to make function get work within foreach dopar?

Pat Amat
  • 23
  • 7
  • Possible duplicate of [could not find function inside foreach loop](http://stackoverflow.com/questions/4765256/could-not-find-function-inside-foreach-loop) – nrussell Dec 27 '16 at 17:22
  • I cannot find an object, not a function. I believe there is a difference between function and object. My object is called "A" which is just coincidentally the same name as the name of a function in the thread you posted. My problem is, that I cannot retrieve an object within foreach loop when using get function. – Pat Amat Dec 27 '16 at 17:26
  • 1
    See the `.export` argument, **which is described in the help file** `?foreach`: *"**.export** character vector of variables to export. This can be useful when accessing a variable that isn't defined in the current environment. The default value in NULL."* – nrussell Dec 27 '16 at 17:31
  • also see `.verbose` which is a _logical flag enabling verbose messages. This can be very useful for trouble shooting._ – manotheshark Dec 27 '16 at 17:39
  • 3
    Possible duplicate of [Foreach loop unable to find object](http://stackoverflow.com/questions/28200982/foreach-loop-unable-to-find-object) – manotheshark Dec 27 '16 at 17:44
  • @nrussel Thank you very much for recommending`.export` argument. This probably appears to have solved my problem. – Pat Amat Dec 27 '16 at 17:50

0 Answers0