次の問題に直面しています。私はtitle
という列のテーブルを持っています。分割列がR
title
列には、To kill a mockingbird (1960)
のような値の行が含まれています。
したがって、基本的に列の形式は[title] ([year])
です。私が必要とするのは、2つの列:title
とyear
、year
です。
もう1つの問題は、括弧を含むタイトルが含まれている行があります。しかし、 では、基本的に各行の最後の6文字が角かっこで囲まれています。
title
とyear
の2つの列を作成するにはどうすればよいですか?
私は何を持っていることは次のとおりです。
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)
私は必要なものは次のとおりです。
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
[再現可能な例](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)を提供する必要があります –