[R] Delete components of a list

Henrique Dallazuanna wwwhsd at gmail.com
Mon Jan 25 20:42:35 CET 2010


Try this:

# Exclude the first column:
lapply(l, '[', -1)

# Remove the second row:
lapply(l, '[', , i = -2)



On Mon, Jan 25, 2010 at 5:37 PM, Lisa <lisajca at gmail.com> wrote:
>
> Dear all,
>
> I have a question about deleting components of a list. For example, I have a
> list that looks like this:
>
> [[1]]
> var1 var2 var3
>   1    3    4
>   2    2    1
>
> [[2]]
> var1 var2 var3
>   2    5    1
>   2    1    7
>
> [[3]]
> var1 var2 var3
>   1    6    7
>   3    8    4
>
> How to delete, say, the first columns of the list or the second rows? Thank
> in advance.
>
> Lisa
>
> --
> View this message in context: http://n4.nabble.com/Delete-components-of-a-list-tp1289732p1289732.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list