0

I made a loop that generates directions inside a list I have using paste function
s=noquote(paste('saa_2$udg[["',Criterios_codigos[a],'"]]',sep ="" ))

, the result is something like this

saa_2$udg[["as1"]]\
saa_2$udg[["et2"]]\
saa_2$udg[["gm3"]]

etc...

I have done this with objects, then I simply use

get(object) and it gives me the result to place on a data frame or whatever.

But since "saa_2$udg[["as1"]]" is a direction inside a list, get() doesn't work, and I cant seem to find a way for it to give me the value stored in that direction.

The direction is correct; if I simply copy and paste the direction
saa_2$udg[["as1"]]
for example, and paste it in the console, it gives me the value stored in that location of the list

  • You can try with `eval(parse(...))`, but usually this is a very bad way to go about things: easy to introduce bugs, difficult to debug, hard to maintain, and very hard to read. You can probably do something like `saa_2$udg[[Criterios_codigos[a]]]` directly without `paste`, `noquote`, `get`, `eval`, or `parse`, but it's hard to tell without more context. – Gregor Thomas Nov 18 '21 at 03:50
  • 1
    saa_2$udg[[Criterios_codigos[a]]] ; damn, it was so easy... just couldnt see it. – Carlos Valdes Nov 18 '21 at 04:08

0 Answers0