I have a problem with my dataset. Here is my data:

```
df <- data.frame(OTU=c(1,2,3),
             Domain=c("Bacteria", "Bacteria", "Archaea"),
             Phylum= c("Atribacteria", "Proteobacteria", "uncultured 
             archaea"),
             Class =c("JS1", "uncultured bacterium", "uncultured archaea"),
             Order=c("uncultured bacterium", "uncultured", 
                     "Ambiguous_taxa"),
             Family=c("uncultured bacterium", "uncultured", 
                      "Ambiguous_taxa"), stringsAsFactors = FALSE)
df

OTU   Domain             Phylum                Class                Order               Family
1   1 Bacteria       Atribacteria                  JS1 uncultured bacterium uncultured bacterium
2   2 Bacteria     Proteobacteria uncultured bacterium           uncultured           uncultured
3   3  Archaea uncultured archaea   uncultured archaea       Ambiguous_taxa       Ambiguous_taxa

```

Summary of my question: Here I would like to change the every text starting with uncultured or Ambiguous with the left column info. If there is more than "uncultured or Ambiguous" written column, It should get the information from the left columns where it has a specific name. For example: In the Order column of third row I have "Ambiguous taxa". So this row should get its name from the Domain where it finds a name without any uncultured or ambiguous in it. So, all the other columns in the right of "Phylum" column should be "uncultured Archaea". Here is the output table that I want to see:

```
     OTU   Domain          Phylum                     Class                     Order                    Family
1   1 Bacteria       Atribacteria                       JS1            uncultured JS1            uncultured JS1
2   2 Bacteria     Proteobacteria uncultured Proteobacteria uncultured Proteobacteria uncultured Proteobacteria
3   3  Archaea uncultured Archaea        uncultured Archaea        uncultured Archaea        uncultured Archaea 

```

I have tried to that in for loop but failed to do so. I am getting warnings and it is not changing anything. I am kind of new to "R". I am trying to say, find "uncultured" pattern using grep in the Order column and change it to for example to "uncultured JS1" using paste function for every "uncultured" pattern that it finds.

```
> Changing_uncultured <- function(DATA){ for(i in 1:length(DATA$Order))
> {    if(grep("uncultured", DATA$Order)) {
>     DATA$Order[i] <- paste("uncultured", DATA$Class[i])   }   }  }
Changing_uncultured(DATA=df)

```

Thanks in advance. Sorry for edits, It is my fault that I did not consider the fact that the uncultured names can start from any column. Now It reflects the actual data.