Hi,

Not sure if this is the issue or not, but it looks like the code you're using overwrites `geno_time` with the output of `str_extract`. So if `geno_time` starts out as your data.frame with a `time` column, the code will run the first time, but the next time you try it, you'll get that error.

Maybe you meant to add a date column?
```
geno_time$date <- str_extract(geno_time$time,"[0-9]+\\/[0-9]+\\/[0-9]+[:blank:]?")
```

Best,
--
Hao Ye

On Fri, Jul 27, 2018 at 3:31 PM, El Rouby,Nihal M <[log in to unmask]> wrote:

Dear All-

 

Trying to extract dates from a variable in a data frame and then make a new column with these dates. I’m using regular expression along str_extract command from package stringr.

 

I’m getting the error  “Error in geno_time$time : $ operator is invalid for atomic vectors” when I used this command below on my dataframe.

 

geno_time<-str_extract(geno_time$time,"[0-9]+\\/[0-9]+\\/[0-9]+[:blank:]?")

 

I’m attaching example of my data and what I want to accomplish.

 

I appreciate your input and have a great weekend.

 

Best,

Nihal

This list strives to be beginner friendly. However, we still ask that you PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

This list strives to be beginner friendly. However, we still ask that you PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.