R 2.13.1 OS X Colleagues I frequently encounter a situation in which I want to remove a single element of an array. For example, if I am reading in a bunch of CSV files, I create the list of files to be read with: LIST <- dir() However, sometimes I want to exclude one or more files. I can accomplish this with a second command: LIST <- LIST[LIST != "filename.to.be.excluded"] This is cumbersome -- is there some more efficient code to accomplish this? Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com [[alternative HTML version deleted]]
On Sep 18, 2011, at 10:47 AM, Dennis Fisher wrote:> R 2.13.1 > OS X > > Colleagues > > I frequently encounter a situation in which I want to remove a > single element of an array. For example, if I am reading in a bunch > of CSV files, I create the list of files to be read with: > LIST <- dir() > However, sometimes I want to exclude one or more files. I can > accomplish this with a second command: > LIST <- LIST[LIST != "filename.to.be.excluded"] > This is cumbersome -- is there some more efficient code to > accomplish this?Doesn't negative indexing provide this? ?Extract -- David Winsemius, MD West Hartford, CT