Skip to content

Delete components of a list

3 messages · Lisa, Henrique Dallazuanna

#
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
#
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: