推 andrew43: 可以直接用中括號來選列。 12/16 20:24
大大您好,我把filter原本用的 () 改成了 [],但依然顯示以下錯誤
Error in filter[(grep("屯區藝文中心->\\d*",
BusData_51$UniqueBusID, value = T))] :
object of type 'closure' is not subsettable
請問這個錯誤代表的意思是什麼? 應該如何改才能解決?
感謝
※ 編輯: joson4921 (1.161.164.166), 12/16/2016 23:45:11
→ clansoda: hi,filter needs boolean vector, try grepl 12/16 23:57
將原本的 grep 改成用 grepl之後產生了以下errer,
或許可能是像andrew43大大說的,filter不吃用 grep 出來的資料
Error in filter[grepl("莒光新城->\\d*|屯區藝文中心->\\d*",
BusData_51$UniqueBusID)] :
object of type 'closure' is not subsettable
以下取自andrew43大大在下一篇回文中提供的寫法:
===============================================================
selection <- BusData_51 %>%
.[grep("莒光新城->\\d*|屯區藝文中心->\\d*", .$UniqueBusID), ]
===============================================================
selection是拿來存放 資料來源(即BusData_51) 經過 grep 處理後的結果
我要做的是針對BusData_51中的 UniqueBusID 欄位內容做過濾
只取 UniqueBusID 欄位內含 莒光新城-> 或 屯區藝文中心-> 字串的資料列
以上,非常感謝各位大大協助提供諮詢
※ 編輯: joson4921 (1.161.164.166), 12/17/2016 16:13:46