Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • I'm having a similar problem, but with a slightly different scope. However, I think it's close enough to not warrant a second question. I want to assign a value to a specific index in a column of tibble. I tried several things already and haven't found anything on here. I would like to do something like: data=tibble(row=c(1,1,1, 2,2,2, 3,3,3), col=c(1,2,3, 1,2,3, 1,2,3), x=c(0.5, 0.5, 0.5, 0.4, 0.4, 0.4, 0.3, 0.3, 0.3)) eval(parse(text="data"))$row[n]=2 I want to loop over several similar dataframes and n. If anybody has an idea, that would be great. Thanks! Commented Jun 2, 2020 at 15:04
  • @Lotte For all these questions, the answer is: have your data.frames inside a (named) list instead of as separate variables. There’s never a reason to have them as variables — literally everything gets easier by having them in a list. Once you have that, you can write mylist$data$row[n] = 2, or mylist[[name]]$row = 2, where name = "data". Commented Jun 2, 2020 at 15:49