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 lists, so that if the single index i is a vector of length p, alist[[i]] is equivalent to alist[[i1]]...[[ip]] providing all but the final indexing results in a list." As your intent is unclear -- no reproducible example showing the desired result -- I would suggest just using list indexing to access the matrices you wish to change. But maybe this does not satisfy your vague request. Also, something seems screwy in the example you showed: For example, the [[1]][[2]][[1]] component indicates a 2 x 5 matrix, but I see only 3 columns of text. Am I missing something? Cheers, Bert On Thu, Oct 25, 2018 at 6:04 PM Ek Esawi <esaw...@gmail.com> wrote: > 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" > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.