1
このようにdata.frameをフィルタリングする方法はありますか?私はすべての行と列、特定のサブ文字列が発生する場所、次の列を保持したいと思います。データセットの別のカラムを通す行の値に基づいて列を選択する方法
df <- read.table(header=TRUE, stringsAsFactors = FALSE, text =
"date col2 col3 col4 col5 col6
1 boston 22 new_york 15 atlanta 5
2 boston 21 new_york 15 atlanta 0
")
cities <- c('boston', 'atlanta')
#filter by cities
#output
#col2 col3 col5 col6
#boston 22 atlanta 5
#boston 21 atlanta 0