TLDR; I've gotten myself into some trouble. I have a dataframe that I exported into different output files based on column ID. Now, I want to merge data from those files back into the original dataframe *without a common index*, knowing only that their order was preserved *within* the ID grouping.

---

I'm starting with a large dataframe (n > 30,000). One of my columns contains text documents in many different languages (`text`). Another column (`en`) indicates which language the document is.

MWE:

```
df <- data.frame(text = c('this is a test', 'questo è un test', 'cest un test', 'another test', 'un autre essai'),
                 en = c("en", "it", "fr", "en", "fr"))

```

I wanted to translate them all into English, but needed to do it manually without a Google Translate API. First I did the following to obtain a list of all unique non-English entries:

```
noneng <- subset(df, lang_2!="en")
noneng <- subset(noneng, !is.na(text))
noneng <- noneng[!duplicated(noneng[,c('text')]),]

```

I then grouped elements of this list by language group and exported them.

```
# export to sep files
write_mult  = function(x) {
write.table(x,paste0("translate/untranslated_",unique(x$lang_1),".txt"))
  return(x)
}

noneng %>% 
  group_by(lang_1) %>% 
  do(write_mult(.))

```

I end up with a bunch of delimited .txt files, one for each language group ID. Within each .txt is the complete list of unique rows for that language group.

```
untranslated_en.txt (2 entries)
untranslated_it.txt (2 entries)
untranslated_fr.txt (1 entry)
...

```

I painstakingly ran these through Google Translate and now have English language versions for each row of each .txt. I was planning on replacing the untranslated versions in the original dataframe with its translation.

What I (foolishly) didn't think about in advance was how I was going to match the translated versions back to the untranslated ones in original dataframe without having given them an index/key of some kind.

There must be a way out of this. For example,

* I know the original order of `noneng` before I exported it
* `group_by` and `unique` must have predictable output based on the order they're given.

So it seems like it should be possible to recover the order of the .txt files even without an index column.

If I knew that, then I could merge them based on order, even without an index. But having split the output into multiple .txts has thrown me off, and I'm totally stumped about how one would backward induct this with R?

I hope I'm explaining this clearly. I'd be grateful for any help.