Re: [R] remove text from nested list

2018-10-25 Thread Ek Esawi
Thank you Bert and Peter. My apology for posting poor code. I cannot create a reproducible example of my data, but i hope the list indices as shown below helps you understand my question.. My regex pattern on my previous post works correctly because i tested it on a few sublists and it worked, but

Re: [R] remove text from nested list

2018-10-25 Thread William Dunlap via R-help
If your matrices are at various depths in the list, try rapply(). E.g., > L <- list( A = list( a1 = matrix(c("AAA","AB", "AAB","AC"),2,2), a2=c("AAx")), list(B = c("AAb1AAA","AAb2"))) > str(L) List of 2 $ A:List of 2 ..$ a1: chr [1:2, 1:2] "AAA" "AB" "AAB" "AC" ..$ a2: chr "AAx" $ :List o

Re: [R] remove text from nested list

2018-10-25 Thread Bert Gunter
1. Please learn how to use dput() to provide examples to responders. There's not much we can do with a text printout (at least without some work that I don't care to do). 2. Do you know what mylist[[c(1,2,1)]] means? If not, read ?(Extract) and note in particular: "[[ can be applied recursively to

Re: [R] remove text from nested list

2018-10-25 Thread Peter Langfelder
You should be more specific about what you want to replace and with what. The pattern you use, namely "[0-9][0-9]/[0-9[0-9].*com", does not (AFAICS) match any of the strings in your data, so don't be surprised that your commands do not change anything. If you have a correct pattern and replacement

[R] remove text from nested list

2018-10-25 Thread Ek Esawi
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 see