[R] Remove specific rows from nested list of matrices

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Fri Nov 2 19:12:41 CET 2018


A partial dput is no help at all. A complete dput of part of your data is much more likely to be helpful, but only if you see the same problem in it as you do in the full data set.

As to private data... if you want data handling help in a public forum then you need to create a small set of data that illustrates the problem. If you have to manufacture the data by hand we don't care, but it is up to you to communicate a clear question somehow.

On November 2, 2018 10:50:06 AM PDT, Ek Esawi <esawiek using gmail.com> wrote:
>Thank you Jeff and Bert. I know i have to use dput add  provide a
>reproducible example. The problem is that the output,is huge, has many
>nested lists, and the info is private.
>
>Here is the first line of dput(FF) if it helps:
>dput(FF)
>list(list(list(structure(c("12/30 12/30", "01/02 01/02", "01/02 01/02",
>
>Thanks again--EK
>On Fri, Nov 2, 2018 at 11:21 AM Jeff Newmiller
><jdnewmil using dcn.davis.ca.us> wrote:
>>
>> Can you supply the output of
>>
>> dput(FF)
>>
>> ?
>>
>> On November 2, 2018 8:00:08 AM PDT, Ek Esawi <esawiek using gmail.com>
>wrote:
>> >Hi All,
>> >
>> >I have a list that is made up of nested lists, as shown below. I
>want
>> >to remove all rows in each sub-list that start with an empty space,
>> >that’s the first entry of a row is blank; for example, on
>> >[[1]][[1]][[1]] Remove row 4,on [[1]][[1]][[3]] remove row 5, on
>> >[[1]][[2]][[1]] remove row 6, etc.. All rows start with 2 digits/ 2
>> >digits. My formula works on individual sublist but not the whole
>> >list.. I know my indexing is wrong, but don’t know how to fix it.
>> >
>> >
>> >> FF
>> >
>> >[[1]]
>> >[[1]][[1]]
>> >[[1]][[1]][[1]]
>> >[,1]    [,2]   [,3]    [,4] [,5]
>> >[1,] "30/20"   "AAAAAAAA" “    “   "-89"
>> >[2,] "02/20"   "AAAAAAAA” “    “   "-98"
>> >[3,] "02/20"   “AAAAAAA” “    “   "-84"
>> >[4,] “  “ “  “   “
>> >[[1]][[1]][[2]]
>> >[,1]    [,2]
>> >[1,] "02/23" “AAAAAAAA” : 29" “
>> >[2,] "02/23" “AAAAAAAA” ." “
>> >[3,] "02/23" “AAAAAAAA” " “
>> >[4,] "02/23" “AAAAAAAA” "
>> >[[1]][[1]][[3]]
>> >[,1]    [,2]    [,3] [,4] [,5] [,6] [,7]
>> >[1,] "01/09" “AAAAAAAA"    “   “   “   "53"
>> >[2,] "01/09" “AAAAAAAA” "   “   “   “   "403"
>> >[3,] "01/09" “AAAAAAAA” "   “   “   “   "83"
>> >[4,] "01/09" “AAAAAAAA” "   “   “   “   "783"
>> >[5,] “  “  “AAAAAAAA”  3042742181"   “   “   “   “
>> >[[1]][[2]]
>> >[[1]][[2]][[1]]
>> >[,1]  [,2] [,3] [,4] [,5]
>> >[1,] “    “   “   “   “AAAAAAAA” "
>> >[2,] "Standard Purchases"  “   “   “   "
>> >[3,] "24/90 "AAAAAAAA” “   "243"  "
>> >[4,] "24/90 "AAAAAAAA” "   "143"  "
>> >[5,] "24/91 "AAAAAAAA” " “   "143" “
>> >[6,] “    “   “   “   "792"
>> >[[1]][[2]][[2]]
>> >[,1]    [,2]
>> >[1,] "02/23" “AAAAAAAA”: 31" “
>> >[2,] "02/23" “AAAAAAAA”." “
>> >[3,] "02/23" “AAAAAAAA” " “
>> >[4,] "02/23" “AAAAAAAA”
>> >[5,] "02/23" “AAAAAAAA”
>> >[6,] "02/23" “AAAAAAAA” 20"
>> >[7,] "02/23" “AAAAAAAA”  “
>> >[8,] "02/23" “AAAAAAAA” "33"
>> >[[1]][[3]]
>> >[[1]][[3]][[1]]
>> >[,1]    [,2]
>> >[1,] "02/23" “AAAAAAAA”: 28" “
>> >[2,] "02/23" “AAAAAAAA”." “
>> >[3,] "02/23" “AAAAAAAA” " “
>> >[4,] "02/23" “AAAAAAAA” "
>> >[[1]][[3]][[2]]
>> >[,1]    [,2]    [,3]    [,4] [,5] [,6] [,7]    [,8]    [,9]
>> >[1,] "02/23" “AAAAAAAA” " “   “   "53" "
>> >[2,] "02/24" “AAAAAAAA” " “   “   "
>> >[3,] “  “  “  “   “   “   “  “  "1,241"
>> >[4,] "02/24" "AAAAAAAA”  “   "33”
>> >
>> >My Formula,:
>> >
>> >G <- lapply(FF, function(x) lapply(x, function (y) lapply(y,
>> >function(z)  z[grepl("^[0-9][0-9]/",z[,1]),])))
>> >
>> >The error: Error in z[, 1] : incorrect number of dimensions
>> >
>> >
>> >
>> >Thanks in advance--EK
>> >
>> >______________________________________________
>> >R-help using 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.
>>
>> --
>> Sent from my phone. Please excuse my brevity.

-- 
Sent from my phone. Please excuse my brevity.




More information about the R-help mailing list