Re: [R] Subsetting a list

From: Huntsinger, Reid <>
Date: Wed 19 Oct 2005 - 00:27:54 EST

You have to use "[" instead of "[[" to return a sub-list.

Reid Huntsinger

-----Original Message-----
[] On Behalf Of Dennis Fisher Sent: Tuesday, October 18, 2005 10:12 AM To:
Subject: [R] Subsetting a list


I have created a list in the following manner:

     TEST <- list(c("A1", "A2"), c("B1", "B2"), c("C1", "C2"))

I now want to delete one element from the list, e.g., the third. The command

yields (as expected):

     [1] "C1" "C2"

The command


     Error: attempt to select more than one element

How can I accomplish delete one or more elements from this list?

I am running R2.2.0 on a Linux platform.


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Wed Oct 19 00:44:08 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:01:42 EST