I have a dataframe that contains various fields. An instance being:
Protein Code Sequence CODON XYZ L AATTGCTA MET ABC K ATTGCTA MET-2 JKL B GCTTATA LYS-2
I want to extract information of all the elements in which the column CODON ends with "-2".
Like in this case i get : ABC K ATTGCTA MET-2 JKL B GCTTATA LYS-2
Please suggest the answer.
I used :
od_lig <- filter(odor_lig, CODON== "$-2")
But I got blank data.
Because you are using a regular expression and filter doesn't understand regex directly. Wrap your regex in grepl and also give it the target column and wrap that in your filter function.
please work through any of the many online R tutorials. You could also look up "how to ask questions" and unfortunately it looks like a correct tagging of posts tutorial is also necessary. Maybe you think the $ would signify a regex end matching? try endsWith
What does a value in the CODON column actually look like?