Skip to content
Prev 385839 / 398503 Next

Help with strings

Your desired output seems to be the same as your desired input in your
example, and your data frames have different column names.

Nonetheless, this bit of code will find rows with "alcohol" in column
3, and for those rows replace the contents of column 4 with column 3.
That may not be exactly what you're after, but should get you started.

lapply(mylist, function(x){
x[grepl("alcohol", x[, 3]), 4] <- x[grepl("alcohol", x[, 3]), 3]
x
})

Sarah
On Tue, Sep 29, 2020 at 4:24 PM Andr? Luis Neves <andrluis at ualberta.ca> wrote: