The audacity to do such a thing…

In R:

assign("x", value)

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.

Legit thank you.

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

Create a post

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.6K Comments
  • Modlog