Re: [R] NA and Character(0) in List Element

2013-01-29 Thread Jeff Newmiller
lapply always yields one output for every input. Try using a for loop and only copying the element once you know you want it. You will need an output index counter that is separate from the for loop index, incremented only when you copy an element.

Re: [R] NA and Character(0) in List Element

2013-01-29 Thread Gerrit Eichner
Hi, Benjamin, have you tried for your list with NA-components to use is.na() as follows (where x is assumed to be your list)? x[ !is.na(x)] Hth -- Gerrit On Tue, 29 Jan 2013, Benjamin Ward (ENV) wrote: Hi, This is probably a small query but one I'm struggling with: I have a list in

Re: [R] NA and Character(0) in List Element

2013-01-29 Thread arun
- From: Benjamin Ward (ENV) b.w...@uea.ac.uk To: r-help@r-project.org r-help@r-project.org Cc: Sent: Monday, January 28, 2013 9:21 PM Subject: [R] NA and Character(0) in List Element Hi, This is probably a small query but one I'm struggling with: I have a list in which I had elements which were

[R] NA and Character(0) in List Element

2013-01-28 Thread Benjamin Ward (ENV)
Hi, This is probably a small query but one I'm struggling with: I have a list in which I had elements which were NA, I removed them, by doing: list2 - lapply(list, na.omit), However this leaves the element there with 'character(0)' in place as well as attributes: e.g. [[978]] character(0)