-1

How to convert the numbers of my last column into a letters in which 1=A ,2=C , 3=G , 4=T , 5=^ , 6=!

please I need help,

```

"TCCA^TA!A"
"TT^CAATTAA!C"

test <- list(c("T"="4", "C"="2", "C"="2", "A"="1", "^"="5", "T"="4", "A"="1","!"="6","A"="1"),c("T"="4","T"="4","^"="5","C"="2","A"="1","A"="1","T"="4","T"="4","A"="1","A"="1","!"="6","C"="2"))

oddfunction <- function(test) {
first_column<- test
second_column<- sort(first_column)
third_column<-paste(first_column,second_column)
fourth_column<-sort(third_column)
column_5<-paste(first_column,fourth_column)
column_6<-sort(column_5)
column_7<-paste(first_column,column_6)
column_8<-sort(column_7)
column_9<-paste(first_column,column_8)
column_10<-sort(column_9)
column_11<-paste(first_column,column_10)
df<-data.frame(first_column, second_column, third_column, fourth_column,column_5,column_6,column_7,column_8,column_9,column_10,column_11)
print(df)
}

for (i in test) {
  oddfunction(i)
```
maram
  • 1
  • 1
  • 1
    Hi maram. Welcome to the stack! Please take the [tour] if you haven't already. Your question is much more likely to be answered (and answered more quickly) if you can show your problem through a [minimal, reproducible example](https://stackoverflow.com/a/5965451/4676560) – Captain Hat Oct 26 '22 at 10:23

1 Answers1

1

Use chartr:

chartr("123456", "ACGT^!", "1232126565")
#[1] "ACGCAC!^!^"
Maël
  • 45,206
  • 3
  • 29
  • 67