this post was submitted on 01 Oct 2023
476 points (96.7% liked)

Programmer Humor

32464 readers
518 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

The audacity to do such a thing…

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 11 points 1 year ago* (last edited 1 year ago) (1 children)

Within a loop could be:

for(i in 1:10){
     assign(paste0("listNum", i), list(i, someStringVector[i], i:(i+20), i*value))
}```

And you can also use get() in the same way to dynamically retrieve a variable. 

I've gone so far into coding debauchery that I've dynamically assigned variables from dynamically retrieved ones, and I've done so fairly frequently.
[–] [email protected] 7 points 1 year ago

Legit thank you.

I've wondered on the right way to do this in R.... Too many times.