November 21, 2018

R - Subset of data in a data frame

asubset = somedata[somedata$mth_end_dt >="2016-01-01" & somedata$mth_end_dt <= "2016-12-31",]

Note: [row filter,column filter]

[row filter, ] means all rows matching the filter. all columns without filtering

y = asubset [, c('col5', 'col6')] means all rows but only include 2 columns namely col5 and col6

No comments:

Post a Comment