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 [log in to unmask] 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 https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_&d=DwIFaQ&c=pZJPUDQ3SB9JplYbifm4nt2lEVG5pWx2KikqINpWlZM&r=QWxQId63qB2iSP1ggUL7kQsdfEWUTu6qCGEw8Xuo91A&m=rP-xC3_sj74fZAMis9CdHcpNMiD3vovWgxfgpkmuIFA&s=boTHyzN2rykIZWbHf5Da0VSglWSIoKMb60l6w1F8mak&e= > posting-guide.html > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwMGaQ&c=pZJPUDQ3SB9JplYbifm4nt2lEVG5pWx2KikqINpWlZM&r=SEmRVMqAFbH_Cx3K2dozZfH2QG2rALCjx8XkDKdS6dE&m=T6R-RSm5riVLS3uc4XkFK3DKka0OBHS_xTyuBQFWZEI&s=09WZYsfZUOMxABjBMdwqhoWEJYAjHasn3xzv7Ym38Zg&e=> > 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.