我正在通過並清理具有位置條目的數據集,比如:「Sarasota Florida6h」我不確定爲什麼,但所有字符串都有3或2個字符開始與多家結束:刪除第一個數字後的字符/數字在字符串中R
[413] "Los Angeles11h" "Pittsburgh PA1h"
[415] "London UK18h" "Mumbai India19h"
[417] "Orange County CA1h" "Columbus OH2d"
[419] "4d" "Sarasota Florida6h"
[421] "Toronto9m" "Adelaide Australia7h"
[423] "Wayland MA4h" "Scottsdale AZ USA1h"
[425] "Sydney Australia6d" "Connecticut USA31m"
[427] "United States5m" "Boulder Colorado12h"
[429] "Berlin Germany7h" " India Chaibasa1h"
我需要一個腳本一個數字後刪除所有字母清理這些了: 我已經試過以下,但很明顯,有什麼東西錯在這裏。
follow_dat$loc <- sapply(strsplit(follow_dat$Location, "\\[0-9]"), `[[`, 2)
您的協助感謝。 馬裏
[419]呢? – Sotos