I'm facing the following problem. I've got a table with a column called title
.
The title
column contains rows with values like To kill a mockingbird (1960)
.
So basically the format of the column is [title] ([year])
. What I need are two columns: title
and year
, year
without brackets.
One other problem is that some rows contain a title including brackets. But basically the last 6 characters of every row are year wrapped in brackets.
How do I create the two columns, title
and year
?
What I have is:
Books$title <- c("To kill a mockingbird (1960)", "Harry Potter and the order of the phoenix (2003)", "Of mice and men (something something) (1937)")
title
To kill a mockingbird (1960)
Harry Potter and the order of the phoenix (2003)
Of mice and men (something something) (1937)
What I need is:
Books$title <- c("To kill a mockingbird", "Harry Potter and the order of the phoenix", "Of mice and men (something something)")
Book$year <- c("1960", "2003", "1937")
title year
To kill a mockingbird 1960
Harry Potter and the order of the phoenix 2003
Of mice and men (something something) 1937