Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような data.frame があります。
name Lily(1+2) John(good+1) Tom() Jim Alice(*+#) .....
R ですべての括弧と括弧内のすべてを削除したいのですが、どうすればよいですか?
私のdata.frameは次のように見えることを好みます:
name Lily John Tom Jim Alice ....
ありがとう!
# read your sample data: d <- read.table(text=readClipboard(), header=TRUE, comment='`') # remove strings in parentheses transform(d, name=gsub('\\(.*\\)', '', name)) # name # 1 Lily # 2 John # 3 Tom # 4 Jim # 5 Alice