Hi there,
have some problems in replacing elements in a dataframe.
I have a dataframe (10 columns and ten rows) constituted by letters (ACTG) and I would like to replace each letter with a number:
A <- 1
C <- 2
G <- 3
T <- 4
I tried the following script but it did not work
key <- c('A','T','C','G')
val <- c('1','2','3','4')
lapply(1:11,FUN = function(i){x[x == key[i]] <<- val[i]})
Could anybody help me?
Thank you very much
All the best