[R] Fwd: Conditional inclusion of an element in an R object

2014-01-10 Thread Santosh
My intention is to include certain columns if they meet certain criteria. For example, if b is one of the columns of a1, then keep otherwise don't. HTH.. santosh On Fri, Jan 10, 2014 at 1:01 PM, MacQueen, Don macque...@llnl.gov wrote: Apologies, but all that ifelse() stuff is too hard to

Re: [R] Fwd: Conditional inclusion of an element in an R object

2014-01-10 Thread Bert Gunter
Don's response seems apropos to me. Do you understanding indexing, i.e. the [ operator? If not, you should read An Introduction to R or other tutorial (there are many good ones on the web). If that is not the issue, you need to explain more clearly why his answer does not suffice. Cheers, Bert

Re: [R] Fwd: Conditional inclusion of an element in an R object

2014-01-10 Thread Santosh
I don't think apropos or indexing would help. I am open to your suggestions/tips. I usually get multiple versions of a dataset (even with the same column names). In the source data, I occasionally notice inconsistencies... formatting issues, column naming issues etc.. As shown In the a1

Re: [R] Fwd: Conditional inclusion of an element in an R object

2014-01-10 Thread MacQueen, Don
At the risk of being annoying ... Your original question was, Is there a way to dynamically include columns in a dataframe? The answer is yes. One way, and I think the simplest, is to calculate the names of the columns you want to keep, and then use an expression like I suggested, that is, one

Re: [R] Fwd: Conditional inclusion of an element in an R object

2014-01-10 Thread Jeff Newmiller
I agree with Don... focus on identifying the names of the columns and then use column name indexing to extract the columns you want. You will probably want to rename them to a standard set of names once you have gone to all this trouble... just assign the new vector of names to the names

Re: [R] Fwd: Conditional inclusion of an element in an R object

2014-01-10 Thread Kevin Schiesser
?as.POSIXct for time-formatting. This function makes a structured list of time data, where you specify an input time and format i.e. as.POSIXct('2014-01-09 01:30:00', format='%Y-%m-%d %H:%M:%S') On 1/10/14, 15:24 , Santosh santosh2...@gmail.com wrote: I don't think apropos or indexing would