List rows with specific columns with a specific value in R from dataset -
i have dataset called "flights" , attempting list rows have value of "escanaba, michigan" in column destination. show 5 columns , rows apply escanaba.
currently have...
flights[,c("flightdate","carrier","destination","destcityname","airtime")] that works want, except shows rows.
how call out specific value column in dataset?
this pretty basic indexing question (see e.g here, first hit when googled "r indexing"); need construct logical vector true relevant rows.
flights[flights$destination=="escanaba, michigan", c("flightdate","carrier","destination","destcityname","airtime")] a prettier alternative interactive work (not entirely safe programmatic use):
subset(flights,destination=="escanaba, michigan", select=c(flightdate,carrier, destination,destcityname,airtime)) if want allow more 1 possible value of destination, try %in%
Comments
Post a Comment