0

So I have a big data frame. The sample ID column contains a list of variations on lcl|TP102920_hit_64. All start with lcl|...etc. Unfortunately, later in my code having | becomes a problem. Is there a way to remove all the | from my data? I have tried:

gsub(|,"",data)
recode(data, "|"="")
chartr("|","   ",data)
sub("|","",data)
str_replace_all(data,"|","")
gsubfn("|",data,"")

and variations using "", //, \\\ and $ for fun. All I have managed to do is completely destroy the data frame. Any suggestions?

989
  • 12,579
  • 5
  • 31
  • 53
  • `gsub("\\|","",data)` or `gsub("|","",data, fixed = TRUE)` – David Arenburg Nov 25 '15 at 20:07
  • These produce the same results of destroying the data frame. Any more ideas? – Z.Henderson Nov 25 '15 at 20:15
  • If you have column there you need to specify it as in `gsub("\\|","",data$ID)` and etc. You really need to read the documentation or do some Google searches. The duplicate answer have everything you need to know. If this still doesn't help, you will need to provide a reproducible example. Otherwise we can't help you. – David Arenburg Nov 25 '15 at 20:16

0 Answers0