Re: [R] How to use access results of gregexpr in data frames

2012-03-30 Thread Mauricio Cornejo
Michael, Your suggestion to use sapply solves the problem.Thanks so much for your help Mauricio From: R. Michael Weylandt Cc: "r-help@r-project.org" Sent: Friday, March 30, 2012 8:33 PM Subject: Re: [R] How to use access results of gregexpr in d

Re: [R] How to use access results of gregexpr in data frames

2012-03-30 Thread R. Michael Weylandt
I think when you assign to dframe$all there's more going on than you realize: you're actually using a multi-element list as a column of a data frame which is, while possible, perhaps nonstandard. Perhaps you want this: dframe$all <- t(simplify2array(gregexpr("/", dframe[, 1]))) print(dframe) #

[R] How to use access results of gregexpr in data frames

2012-03-30 Thread Mauricio Cornejo
Hello, I'm trying to figure out how to find the index of the second occurrence of "/" in a string (which happens to represent a date) within a data frame column. I've used the following code successfully to find the first instance of "/". dframe <- data.frame(date=c("5/14/2011", "4/7/2011")) df