我有以下数据
Names[]
[1] John Simon is a great player
[2] Chi-Twi is from china
[3] O'Konnor works hard
[4] R.F is a swimmer
我只需要从所有这些行中提取名称并存储它们。我试过这样做。
[1] John Simon
[2] Chi-Twi
[3] O'Konnor
[4] R.F
names = gsub("(^[A-Z|a-z|.|-|']+[ ]+[A-Z|a-z|.|-|]+)[ ]+.*", "\\1",names)
有人可以帮我吗?