Re: [R] Writing a function to return column position XXXX

2012-01-25 Thread Uwe Ligges
On 25.01.2012 02:16, R. Michael Weylandt wrote: I think you are getting stuck on the same regexp problem as before (i.e., once again the dollar sign is being interpreted as the beginning You meant "end". Uwe of the line rather than an actual dollar sign) If I understand your question, mi

Re: [R] Writing a function to return column position XXXX

2012-01-24 Thread R. Michael Weylandt
I think you are getting stuck on the same regexp problem as before (i.e., once again the dollar sign is being interpreted as the beginning of the line rather than an actual dollar sign) If I understand your question, might I suggest something much easier? x = data.frame(a = c("$1034.23","1,230"),

Re: [R] Writing a function to return column position XXXX

2012-01-24 Thread David Winsemius
On Jan 24, 2012, at 11:07 AM, Dan Abner wrote: Hi everyone, I am using Michael's approach (grepl()) to identify which columns containing $ signs. I was hoping to incorporate this into a line of code that would automatically 1) find which columns contain $ signs, 2) strip the $ and commas, and

Re: [R] Writing a function to return column position XXXX

2012-01-24 Thread Dan Abner
Hi everyone, I am using Michael's approach (grepl()) to identify which columns containing $ signs. I was hoping to incorporate this into a line of code that would automatically 1) find which columns contain $ signs, 2) strip the $ and commas, and 3) convert the result to a numeric vector. I have

Re: [R] Writing a function to return column position XXXX

2012-01-24 Thread Mikko Korpela
On 01/24/2012 03:49 PM, Dan Abner wrote: > Hello everyone, > > I am writing my own function to return the column index of all variables > (these are currently character vectors) in a data frame that contain a > dollar sign($). A small piece of the data look like this: > > can_sta can_zip ind_

Re: [R] Writing a function to return column position XXXX

2012-01-24 Thread R. Michael Weylandt
Either any(grepl("$",x, fixed = TRUE)) # You probably want grepl not grep any(grepl("\\$",x) ) ? regexpr # $ has a special value Michael PS -- Stop with HTML postings (seriously, it actually does mess up what the rest of us see and I think it causes trouble for the archives as well) On Tue, Jan

[R] Writing a function to return column position XXXX

2012-01-24 Thread Dan Abner
Hello everyone, I am writing my own function to return the column index of all variables (these are currently character vectors) in a data frame that contain a dollar sign($). A small piece of the data look like this: can_sta can_zip ind_ite_con ind_uni_con AL 36106 $251,895.80 $22,874.43 AL