Hi, Nihal,


I am not familiar with the package you are using, but to me it looks like it is not recognizing 'geno_time$time" as dataframe$columnName. There could either be a typo or you are feeding the wrong variable to the script.


Also, just from looking at the example, if you are not bound to the specific package, you could just strsplit(spli=' ') (i.e. just by the space between date and time). Unless you do want to use str_extract​ as an exercise or any other reason.


Hope it helps,


Max


Massimiliano S. Tagliamonte
DVM, MSc, PhD
Postdoc Associate
Emerging Pathogens Institute
Department of Pathology
College of Medicine
University of Florida

From: UF R Users List <[log in to unmask]> on behalf of El Rouby,Nihal M <[log in to unmask]>
Sent: Friday, July 27, 2018 3:31 PM
To: [log in to unmask]
Subject: Regular expression
 

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.