[R] remove text from nested list

Ek Esawi e@@wiek @ending from gm@il@com
Fri Oct 26 03:04:09 CEST 2018


Hi All—

I have a list that contains multiple sub-lists and each sub-list
contains multiple  sub(sub-lists), each of the sub(sub-lists) is made
up of matrices of text. I want to replace some of the text in some
parts in the matrices on the list. I tried gsub and stringr,
str_remove, but nothing seems to work

I tried:

lapply(mylist, function(x) lapply(x, function(y)
gsub("[0-9][0-9]/[0-9[0-9].*com","",y)))
lapply(mylist, function(x) str_remove(x,"[0-9][0-9]/[0-9[0-9].*com"))

Any help is greatly apprercaited.



mylist—this is just an example

[[1]]
[[1]][[1]]
[[1]][[1]][[1]]
[,1]  [,2]  [,3]  [,4] [,5]
[1,] "12/30 12/30"  "ABABABABABAB"  "8.00"
[2,] "01/02 01/02"  "AAAAAAAAAAAA”.   “99"
[3,] "01/02 01/02"  "CACACACACACC” "55.97"

[[1]][[1]][[2]]
[,1]  [,2]
[1,] "12/30 12/30" "DDDDDDDDDDDDDDD” “29"
[2,] "12/30 12/30"  :GGGGGGGGGGGGGGG” “333”

[[1]][[2]]
[[1]][[2]][[1]]
[,1]  [,2]  [,3] [,4]  [,5]
[1,]  "01/02 01/02" "ThankYou" “23”
[2,] "01/02 01/02"  "Standard data"  "251"



More information about the R-help mailing list