separate columns with condition

64 Views Asked by At

I have a csv file from movielens that i'm trying to manipulate.

The movie list in my data.frame contains movie title and the year of movie and what i'm trying to separate the year and title to separate columns.

I used the folowing code:

movies <- extract(movies, title, c("title", "year"), "^(.*) \\(([0-9 \\-]*)\\)$")

I succeded to that but there is movies that contains only names and for those movies i get NA for the hole rows instead of getting NA for only "Year" column.

1

There are 1 best solutions below

0
mono1401 On

enter image description here

This is how the results looks