i want to make a function where, if an argument includes "A", "T", "G", "C" n numbers of times and it could replace T into U and gives back all the changed argument, then what should be the appropriate way to code this in R? set of code which i have made or i want to use for y personal preference is=
``` r
data=c("A","T","G","C")
change<-function(compound)
+ {
+ molecules<-unlist(strsplit(compound,""))
+
+
+ gsub("T","U",string)
+ }
change("ATGC")
Error in gsub("T", "U", string) : object 'string' not found
#> Error: <text>:9:3: unexpected '}'
#> 8: + gsub("T","U",string)
#> 9: + }
#> ^
```
Created on 2018-05-22 by the reprex package (v0.2.0).
Argument would be like change("AAAATTTTGGGGCCCCC") and it should give an output=AAAAUUUUGGGGCCCC
Please help me with this problem. Thank you