Hey all, i have a technical problem. i have a 2 column table with a list of GO and respective p-value in R. Now i want to add another column based on a specific pattern in the GO term. e.g. if the GO term starts with GO:002* (for capturing e.g. GO:002545545,GO:002434343, GO:00254457,etc..) i want to add "yes" to the third column, otherwise "no". Does someone know how to do this in R? thanks in advance
I dont understand exactly the pattern but following is the code snippet: add_col <- c() df #data.frame containing the two columns for(i in df[,1]) { if(i matches pattern) add_col <- c(add_col, 'yes') else add_col <- c(add_col, 'no') } cbind(df, add_col)
If pattern is clear I can perhaps write a more proper if.